diff --git a/test/player_unit.js b/test/player_unit.js index 1c5a9ebd04..3a8446e539 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -3343,8 +3343,23 @@ describe('Player', function() { }); }); - describe('get*LanguageAndRoles', function() { - it('returns a list of language/role combinations', async () => { + describe('getAudioLanguagesAndRoles', () => { + it('ignores video roles', async () => { + manifest = new shaka.test.ManifestGenerator() + .addPeriod(0) + .addVariant(0) + .addVideo(1).roles(['video-only-role']) + .addAudio(2).roles(['audio-only-role']).language('en') + .build(); + + await player.load(fakeManifestUri, 0, parserFactory); + + expect(player.getAudioLanguagesAndRoles()).toEqual([ + {language: 'en', role: 'audio-only-role'}, + ]); + }); + + it('lists all language-role combinations', async () => { await player.load(fakeManifestUri, 0, parserFactory); expect(player.getAudioLanguagesAndRoles()).toEqual([ {language: 'fr', role: ''}, @@ -3353,23 +3368,32 @@ describe('Player', function() { {language: 'de', role: 'foo'}, {language: 'de', role: 'bar'}, ]); - expect(player.getTextLanguagesAndRoles()).toEqual([ - {language: 'es', role: 'baz'}, - {language: 'es', role: 'qwerty'}, - {language: 'en', role: 'main'}, - {language: 'en', role: 'caption'}, - {language: 'en', role: 'subtitle'}, - ]); }); - it('returns "und" for video-only tracks', async () => { - manifest = videoOnlyManifest; + it('uses "und" for video-only tracks', async () => { + manifest = new shaka.test.ManifestGenerator() + .addPeriod(0) + .addVariant(0) + .addVideo(1).roles(['video-only-role']) + .build(); await player.load(fakeManifestUri, 0, parserFactory); expect(player.getAudioLanguagesAndRoles()).toEqual([ {language: 'und', role: ''}, ]); - expect(player.getTextLanguagesAndRoles()).toEqual([]); + }); + }); + + describe('getTextLanguageAndRoles', function() { + it('lists all language-role combinations', async () => { + await player.load(fakeManifestUri, 0, parserFactory); + expect(player.getTextLanguagesAndRoles()).toEqual([ + {language: 'es', role: 'baz'}, + {language: 'es', role: 'qwerty'}, + {language: 'en', role: 'main'}, + {language: 'en', role: 'caption'}, + {language: 'en', role: 'subtitle'}, + ]); }); }); });