Skip to content

Commit

Permalink
test: update tests to use qunit 2 assert format (#4753)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey authored and gkatsev committed Nov 16, 2017
1 parent 3aae4b2 commit 06641e8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions test/unit/clickable-component.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions test/unit/controls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
4 changes: 2 additions & 2 deletions test/unit/tech/html5.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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;
Expand Down
42 changes: 21 additions & 21 deletions test/unit/tracks/text-track-controls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]
});
Expand All @@ -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);
Expand All @@ -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]
});
Expand All @@ -427,20 +427,20 @@ 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();

const menu = player.controlBar.chaptersButton.menu;
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);
Expand All @@ -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
Expand All @@ -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();
});

0 comments on commit 06641e8

Please sign in to comment.