-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: TextTrackMenuItem components should not disable text tracks of d…
…ifferent kind(s). (#5741)
- Loading branch information
1 parent
175f773
commit b27f713
Showing
2 changed files
with
84 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/unit/control-bar/text-track-controls/text-track-menu-item.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* eslint-env qunit */ | ||
import TextTrackMenuItem from '../../../../src/js/control-bar/text-track-controls/text-track-menu-item.js'; | ||
import TestHelpers from '../../test-helpers.js'; | ||
|
||
QUnit.module('TextTrackMenuItem', { | ||
beforeEach(assert) { | ||
this.player = TestHelpers.makePlayer(); | ||
}, | ||
afterEach(assert) { | ||
this.player.dispose(); | ||
} | ||
}); | ||
|
||
QUnit.test('clicking should enable the selected track', function(assert) { | ||
assert.expect(2); | ||
|
||
const foo = this.player.addTextTrack('captions', 'foo', 'en'); | ||
|
||
const fooItem = new TextTrackMenuItem(this.player, { | ||
track: foo | ||
}); | ||
|
||
assert.strictEqual(foo.mode, 'disabled', 'track "foo" begins "disabled"'); | ||
|
||
fooItem.trigger('click'); | ||
|
||
assert.strictEqual(foo.mode, 'showing', 'clicking set track "foo" to "showing"'); | ||
|
||
fooItem.dispose(); | ||
}); | ||
|
||
QUnit.test('clicking should disable non-selected tracks of the same kind', function(assert) { | ||
assert.expect(9); | ||
|
||
const foo = this.player.addTextTrack('captions', 'foo', 'en'); | ||
const bar = this.player.addTextTrack('captions', 'bar', 'es'); | ||
const bop = this.player.addTextTrack('metadata', 'bop'); | ||
|
||
bop.mode = 'hidden'; | ||
|
||
const fooItem = new TextTrackMenuItem(this.player, { | ||
track: foo | ||
}); | ||
|
||
const barItem = new TextTrackMenuItem(this.player, { | ||
track: bar | ||
}); | ||
|
||
assert.strictEqual(foo.mode, 'disabled', 'captions track "foo" begins "disabled"'); | ||
assert.strictEqual(bar.mode, 'disabled', 'captions track "bar" begins "disabled"'); | ||
assert.strictEqual(bop.mode, 'hidden', 'metadata track "bop" is "hidden"'); | ||
|
||
barItem.trigger('click'); | ||
|
||
assert.strictEqual(foo.mode, 'disabled', 'captions track "foo" is still "disabled"'); | ||
assert.strictEqual(bar.mode, 'showing', 'captions track "bar" is now "showing"'); | ||
assert.strictEqual(bop.mode, 'hidden', 'metadata track "bop" is still "hidden"'); | ||
|
||
fooItem.trigger('click'); | ||
|
||
assert.strictEqual(foo.mode, 'showing', 'captions track "foo" is now "showing"'); | ||
assert.strictEqual(bar.mode, 'disabled', 'captions track "bar" is now "disabled"'); | ||
assert.strictEqual(bop.mode, 'hidden', 'metadata track "bop" is still "hidden"'); | ||
|
||
fooItem.dispose(); | ||
barItem.dispose(); | ||
}); |