mirror of
https://github.com/videojs/video.js.git
synced 2025-07-13 01:30:17 +02:00
test: update tests to use qunit 2 assert format (#4753)
This commit is contained in:
committed by
Gary Katsevman
parent
3aae4b2336
commit
06641e8694
@ -41,7 +41,7 @@ QUnit.test('should be enabled/disabled', function(assert) {
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('handleClick should not be triggered when disabled', function() {
|
||||
QUnit.test('handleClick should not be triggered when disabled', function(assert) {
|
||||
let clicks = 0;
|
||||
|
||||
class TestClickableComponent extends ClickableComponent {
|
||||
@ -56,23 +56,23 @@ QUnit.test('handleClick should not be triggered when disabled', function() {
|
||||
|
||||
// 1st click
|
||||
Events.trigger(el, 'click');
|
||||
QUnit.equal(clicks, 1, 'click on enabled ClickableComponent is handled');
|
||||
assert.equal(clicks, 1, 'click on enabled ClickableComponent is handled');
|
||||
|
||||
testClickableComponent.disable();
|
||||
// No click should happen.
|
||||
Events.trigger(el, 'click');
|
||||
QUnit.equal(clicks, 1, 'click on disabled ClickableComponent is not handled');
|
||||
assert.equal(clicks, 1, 'click on disabled ClickableComponent is not handled');
|
||||
|
||||
testClickableComponent.enable();
|
||||
// 2nd Click
|
||||
Events.trigger(el, 'click');
|
||||
QUnit.equal(clicks, 2, 'click on re-enabled ClickableComponent is handled');
|
||||
assert.equal(clicks, 2, 'click on re-enabled ClickableComponent is handled');
|
||||
|
||||
testClickableComponent.dispose();
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('handleClick should not be triggered more than once when enabled', function() {
|
||||
QUnit.test('handleClick should not be triggered more than once when enabled', function(assert) {
|
||||
let clicks = 0;
|
||||
|
||||
class TestClickableComponent extends ClickableComponent {
|
||||
@ -88,7 +88,7 @@ QUnit.test('handleClick should not be triggered more than once when enabled', fu
|
||||
testClickableComponent.enable();
|
||||
// Click should still be handled just once
|
||||
Events.trigger(el, 'click');
|
||||
QUnit.equal(clicks, 1, 'no additional click handler when already enabled ClickableComponent has been enabled again');
|
||||
assert.equal(clicks, 1, 'no additional click handler when already enabled ClickableComponent has been enabled again');
|
||||
|
||||
testClickableComponent.dispose();
|
||||
player.dispose();
|
||||
|
@ -90,16 +90,16 @@ QUnit.test('should hide playback rate control if it\'s not supported', function(
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
QUnit.test('Fullscreen control text should be correct when fullscreenchange is triggered', function() {
|
||||
QUnit.test('Fullscreen control text should be correct when fullscreenchange is triggered', function(assert) {
|
||||
const player = TestHelpers.makePlayer();
|
||||
const fullscreentoggle = new FullscreenToggle(player);
|
||||
|
||||
player.isFullscreen(true);
|
||||
player.trigger('fullscreenchange');
|
||||
QUnit.equal(fullscreentoggle.controlText(), 'Non-Fullscreen', 'Control Text is correct while switching to fullscreen mode');
|
||||
assert.equal(fullscreentoggle.controlText(), 'Non-Fullscreen', 'Control Text is correct while switching to fullscreen mode');
|
||||
player.isFullscreen(false);
|
||||
player.trigger('fullscreenchange');
|
||||
QUnit.equal(fullscreentoggle.controlText(), 'Fullscreen', 'Control Text is correct while switching back to normal mode');
|
||||
assert.equal(fullscreentoggle.controlText(), 'Fullscreen', 'Control Text is correct while switching back to normal mode');
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
|
@ -686,7 +686,7 @@ QUnit.test('Html5#reset calls Html5.resetMediaElement when called', function(ass
|
||||
Html5.resetMediaElement = oldResetMedia;
|
||||
});
|
||||
|
||||
test('When Android Chrome reports Infinity duration with currentTime 0, return NaN', function() {
|
||||
QUnit.test('When Android Chrome reports Infinity duration with currentTime 0, return NaN', function(assert) {
|
||||
const oldIsAndroid = browser.IS_ANDROID;
|
||||
const oldIsChrome = browser.IS_CHROME;
|
||||
const oldEl = tech.el_;
|
||||
@ -698,7 +698,7 @@ test('When Android Chrome reports Infinity duration with currentTime 0, return N
|
||||
duration: Infinity,
|
||||
currentTime: 0
|
||||
};
|
||||
ok(Number.isNaN(tech.duration()), 'returned NaN with currentTime 0');
|
||||
assert.ok(Number.isNaN(tech.duration()), 'returned NaN with currentTime 0');
|
||||
|
||||
browser.IS_ANDROID = oldIsAndroid;
|
||||
browser.IS_CHROME = oldIsChrome;
|
||||
|
@ -324,29 +324,29 @@ const chaptersTrack = {
|
||||
label: 'Test Chapters'
|
||||
};
|
||||
|
||||
test('chapters should not be displayed when text tracks list is empty', function() {
|
||||
QUnit.test('chapters should not be displayed when text tracks list is empty', function(assert) {
|
||||
const player = TestHelpers.makePlayer();
|
||||
|
||||
ok(player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'control is not displayed');
|
||||
equal(player.textTracks().length, 0, 'textTracks is empty');
|
||||
assert.ok(player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'control is not displayed');
|
||||
assert.equal(player.textTracks().length, 0, 'textTracks is empty');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('chapters should not be displayed when there is chapters track but no cues', function() {
|
||||
QUnit.test('chapters should not be displayed when there is chapters track but no cues', function(assert) {
|
||||
const player = TestHelpers.makePlayer({
|
||||
tracks: [chaptersTrack]
|
||||
});
|
||||
|
||||
this.clock.tick(1000);
|
||||
|
||||
ok(player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is not displayed');
|
||||
equal(player.textTracks().length, 1, 'textTracks contains one item');
|
||||
assert.ok(player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is not displayed');
|
||||
assert.equal(player.textTracks().length, 1, 'textTracks contains one item');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('chapters should be displayed when cues added to initial track and button updated', function() {
|
||||
QUnit.test('chapters should be displayed when cues added to initial track and button updated', function(assert) {
|
||||
const player = TestHelpers.makePlayer({
|
||||
tracks: [chaptersTrack]
|
||||
});
|
||||
@ -365,20 +365,20 @@ test('chapters should be displayed when cues added to initial track and button u
|
||||
endTime: 4,
|
||||
text: 'Chapter 2'
|
||||
});
|
||||
equal(chapters.cues.length, 2);
|
||||
assert.equal(chapters.cues.length, 2);
|
||||
|
||||
player.controlBar.chaptersButton.update();
|
||||
|
||||
ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
assert.ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
|
||||
const menuItems = player.controlBar.chaptersButton.items;
|
||||
|
||||
equal(menuItems.length, 2, 'menu contains two item');
|
||||
assert.equal(menuItems.length, 2, 'menu contains two item');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('chapters should be displayed when a track and its cures added and button updated', function() {
|
||||
QUnit.test('chapters should be displayed when a track and its cures added and button updated', function(assert) {
|
||||
const player = TestHelpers.makePlayer();
|
||||
|
||||
this.clock.tick(1000);
|
||||
@ -395,20 +395,20 @@ test('chapters should be displayed when a track and its cures added and button u
|
||||
endTime: 4,
|
||||
text: 'Chapter 2'
|
||||
});
|
||||
equal(chapters.cues.length, 2);
|
||||
assert.equal(chapters.cues.length, 2);
|
||||
|
||||
player.controlBar.chaptersButton.update();
|
||||
|
||||
ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
assert.ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
|
||||
const menuItems = player.controlBar.chaptersButton.items;
|
||||
|
||||
equal(menuItems.length, 2, 'menu contains two item');
|
||||
assert.equal(menuItems.length, 2, 'menu contains two item');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('chapters menu should use track label as menu title', function() {
|
||||
QUnit.test('chapters menu should use track label as menu title', function(assert) {
|
||||
const player = TestHelpers.makePlayer({
|
||||
tracks: [chaptersTrack]
|
||||
});
|
||||
@ -427,7 +427,7 @@ test('chapters menu should use track label as menu title', function() {
|
||||
endTime: 4,
|
||||
text: 'Chapter 2'
|
||||
});
|
||||
equal(chapters.cues.length, 2);
|
||||
assert.equal(chapters.cues.length, 2);
|
||||
|
||||
player.controlBar.chaptersButton.update();
|
||||
|
||||
@ -435,12 +435,12 @@ test('chapters menu should use track label as menu title', function() {
|
||||
const titleEl = menu.contentEl().firstChild;
|
||||
const menuTitle = titleEl.textContent || titleEl.innerText;
|
||||
|
||||
equal(menuTitle, 'Test Chapters', 'menu gets track label as title');
|
||||
assert.equal(menuTitle, 'Test Chapters', 'menu gets track label as title');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
||||
test('chapters should be displayed when remote track added and load event fired', function() {
|
||||
QUnit.test('chapters should be displayed when remote track added and load event fired', function(assert) {
|
||||
const player = TestHelpers.makePlayer();
|
||||
|
||||
this.clock.tick(1000);
|
||||
@ -458,7 +458,7 @@ test('chapters should be displayed when remote track added and load event fired'
|
||||
text: 'Chapter 2'
|
||||
});
|
||||
|
||||
equal(chaptersEl.track.cues.length, 2);
|
||||
assert.equal(chaptersEl.track.cues.length, 2);
|
||||
|
||||
// Anywhere where we support using native text tracks, we can trigger a custom DOM event.
|
||||
// On IE8 and other places where we have emulated tracks, either we cannot trigger custom
|
||||
@ -470,11 +470,11 @@ test('chapters should be displayed when remote track added and load event fired'
|
||||
chaptersEl.trigger('load');
|
||||
}
|
||||
|
||||
ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
assert.ok(!player.controlBar.chaptersButton.hasClass('vjs-hidden'), 'chapters menu is displayed');
|
||||
|
||||
const menuItems = player.controlBar.chaptersButton.items;
|
||||
|
||||
equal(menuItems.length, 2, 'menu contains two item');
|
||||
assert.equal(menuItems.length, 2, 'menu contains two item');
|
||||
|
||||
player.dispose();
|
||||
});
|
||||
|
Reference in New Issue
Block a user