Files
shaka-player/test/offline/offline_uri_unit.js
T
Aaron Vaage 967f339934 Mark Version 2 of DB Engine
externs/shaka/offline.js now represents the data types for Shaka Player
Offline V2. All offline shaka player code uses the new version and all
V1 and transitional code has been removed.

Issue #1047

Change-Id: Ia43f8d8d11426e823629e5fcd27c4e1e0ce400d3
2017-12-16 00:11:04 +00:00

76 lines
2.0 KiB
JavaScript

/**
* @license
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
describe('OfflineUri', function() {
/** @const */
var OfflineUri = shaka.offline.OfflineUri;
it('creates uri from manifest id', function() {
/** @type {number} */
var id = 123;
/** @type {string} */
var uri = OfflineUri.manifestIdToUri(id);
expect(uri).toBe('offline:manifest/123');
});
it('creates uri from segment id', function() {
/** @type {number} */
var id = 123;
/** @type {string} */
var uri = OfflineUri.segmentIdToUri(id);
expect(uri).toBe('offline:segment/123');
});
it('creates null id from non-manifest uri', function() {
/** @type {string} */
var uri = 'invalid-uri';
/** @type {?number} */
var id = OfflineUri.uriToManifestId(uri);
expect(id).toBeNull();
});
it('creates id from manifest uri', function() {
/** @type {string} */
var uri = 'offline:manifest/123';
/** @type {?number} */
var id = OfflineUri.uriToManifestId(uri);
expect(id).toBe(123);
});
it('creates null id from non-segment uri', function() {
/** @type {string} */
var uri = 'invalid-uri';
/** @type {?number} */
var id = OfflineUri.uriToSegmentId(uri);
expect(id).toBeNull();
});
it('creates id from segment uri', function() {
/** @type {string} */
var uri = 'offline:segment/123';
/** @type {?number} */
var id = OfflineUri.uriToSegmentId(uri);
expect(id).toBe(123);
});
});