Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Apr 30, 2021
1 parent 4155346 commit 20fe047
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions test/media-groups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 20fe047

Please sign in to comment.