mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-18 16:36:56 +03:00
56a53db33f
Change-Id: I08044eaefa12a7871664085026ff73ee0bebd5c4
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
/*! @license
|
|
* Shaka Player
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.require('shaka.offline.OfflineUri');
|
|
|
|
describe('OfflineUri', () => {
|
|
const OfflineUri = shaka.offline.OfflineUri;
|
|
|
|
it('creates uri from manifest id', () => {
|
|
/** @type {number} */
|
|
const id = 123;
|
|
/** @type {string} */
|
|
const uri = OfflineUri.manifest('mech', 'cell', id).toString();
|
|
|
|
expect(uri).toBe('offline:manifest/mech/cell/123');
|
|
});
|
|
|
|
it('creates uri from segment id', () => {
|
|
/** @type {number} */
|
|
const id = 123;
|
|
/** @type {string} */
|
|
const uri = OfflineUri.segment('mech', 'cell', id).toString();
|
|
|
|
expect(uri).toBe('offline:segment/mech/cell/123');
|
|
});
|
|
|
|
it('creates null from invalid uri', () => {
|
|
/** @type {string} */
|
|
const uri = 'invalid-uri';
|
|
const parsed = OfflineUri.parse(uri);
|
|
|
|
expect(parsed).toBeNull();
|
|
});
|
|
|
|
it('parse manifest uri', () => {
|
|
/** @type {string} */
|
|
const uri = 'offline:manifest/mech/cell/123';
|
|
const parsed = OfflineUri.parse(uri);
|
|
|
|
expect(parsed).toBeTruthy();
|
|
expect(parsed.isManifest()).toBeTruthy();
|
|
expect(parsed.mechanism()).toBe('mech');
|
|
expect(parsed.cell()).toBe('cell');
|
|
expect(parsed.key()).toBe(123);
|
|
});
|
|
|
|
it('parse segment uri', () => {
|
|
/** @type {string} */
|
|
const uri = 'offline:segment/mech/cell/123';
|
|
const parsed = OfflineUri.parse(uri);
|
|
|
|
expect(parsed).toBeTruthy();
|
|
expect(parsed.isSegment()).toBeTruthy();
|
|
expect(parsed.mechanism()).toBe('mech');
|
|
expect(parsed.cell()).toBe('cell');
|
|
expect(parsed.key()).toBe(123);
|
|
});
|
|
});
|