diff --git a/test/media-groups.test.js b/test/media-groups.test.js index 799154091..367d8bebc 100644 --- a/test/media-groups.test.js +++ b/test/media-groups.test.js @@ -257,17 +257,17 @@ QUnit.module('MediaGroups', function() { this.media = null; - const settings = { + this.settings = { mediaTypes: MediaGroups.createMediaTypes(), masterPlaylistLoader: { media: () => this.media } }; - this.groups = settings.mediaTypes[groupType].groups; - this.tracks = settings.mediaTypes[groupType].tracks; - this.activeTrack = MediaGroups.activeTrack[groupType](groupType, settings); - this.activeGroup = MediaGroups.activeGroup(groupType, settings); + this.groups = this.settings.mediaTypes[groupType].groups; + this.tracks = this.settings.mediaTypes[groupType].tracks; + this.activeTrack = MediaGroups.activeTrack[groupType](groupType, this.settings); + this.activeGroup = MediaGroups.activeGroup(groupType, this.settings); }, afterEach(assert) { sharedHooks.afterEach.call(this, assert); @@ -320,6 +320,57 @@ QUnit.module('MediaGroups', function() { assert.equal(this.activeGroup({id: 'baz'}), null, 'no group with invalid track'); }); + if (groupType === 'AUDIO') { + QUnit.test('hls audio only playlist returns correct group', function(assert) { + this.media = { + id: 'fr-bar', + attributes: {CODECS: 'mp4a.40.2'} + }; + + this.settings.master = { + mediaGroups: { + AUDIO: this.groups + } + }; + + this.groups.main = [{ id: 'en', uri: 'en.ts'}, { id: 'fr', uri: 'fr.ts' }]; + this.groups.foo = [{ id: 'en-foo', uri: 'en-foo.ts' }, { id: 'fr-foo', uri: 'fr-foo.ts' }]; + this.groups.bar = [{ id: 'en-bar', uri: 'en-foo.ts' }, { id: 'fr-bar', uri: 'fr-bar.ts' }]; + + assert.deepEqual(this.activeGroup(), this.groups.bar, 'selected matching group'); + }); + QUnit.test('dash audio only playlist returns correct group', function(assert) { + this.media = { + uri: 'fr-bar-1.ts', + attributes: {CODECS: 'mp4a.40.2'} + }; + + this.settings.master = { + mediaGroups: { + AUDIO: this.groups + } + }; + + ['main', 'foo', 'bar'].forEach((key) => { + this.groups[key] = [{ + label: 'en', + playlists: [ + {id: `en-${key}-0`, uri: `en-${key}-0.ts`}, + {id: `en-${key}-1`, uri: `en-${key}-1.ts`} + ] + }, { + label: 'fr', + playlists: [ + {id: `fr-${key}-0`, uri: `fr-${key}-0.ts`}, + {id: `fr-${key}-1`, uri: `fr-${key}-1.ts`} + ] + }]; + }); + + assert.deepEqual(this.activeGroup(), this.groups.bar, 'selected matching group'); + }); + } + QUnit.module(`${groupType} getActiveGroup `, { beforeEach(assert) { sharedHooks.beforeEach.call(this, assert);