From 72c44daaf3733ef3d0bd9b9a7893e38e0893ce16 Mon Sep 17 00:00:00 2001 From: "Pat O'Neill" Date: Fri, 12 Aug 2016 13:51:31 -0400 Subject: [PATCH] @misteroneill updated tests to qunit 2.0. closes #3509 --- CHANGELOG.md | 1 + package.json | 2 +- test/api/api.js | 308 ++++++------ test/unit/button.test.js | 10 +- test/unit/clickable-component.test.js | 18 +- test/unit/component.test.js | 339 ++++++------- test/unit/controls.test.js | 32 +- test/unit/events.test.js | 90 ++-- test/unit/extend.test.js | 6 +- test/unit/menu.test.js | 26 +- test/unit/player.test.js | 448 +++++++++--------- test/unit/plugins.test.js | 56 +-- test/unit/poster.test.js | 30 +- test/unit/setup.test.js | 8 +- test/unit/tech/flash-rtmp.test.js | 54 +-- test/unit/tech/flash.test.js | 102 ++-- test/unit/tech/html5.test.js | 194 ++++---- test/unit/tech/tech.test.js | 224 ++++----- test/unit/tracks/audio-track-list.test.js | 62 +-- test/unit/tracks/audio-track.test.js | 58 +-- test/unit/tracks/audio-tracks.test.js | 26 +- .../tracks/html-track-element-list.test.js | 48 +- test/unit/tracks/html-track-element.test.js | 43 +- test/unit/tracks/text-track-controls.test.js | 120 ++--- test/unit/tracks/text-track-cue-list.test.js | 54 +-- .../tracks/text-track-list-converter.test.js | 24 +- test/unit/tracks/text-track-list.test.js | 8 +- test/unit/tracks/text-track-settings.test.js | 78 +-- test/unit/tracks/text-track.test.js | 118 ++--- test/unit/tracks/text-tracks.test.js | 136 +++--- test/unit/tracks/track-baseline.js | 26 +- test/unit/tracks/track-list.test.js | 64 +-- test/unit/tracks/track.test.js | 10 +- test/unit/tracks/video-track-list.test.js | 62 +-- test/unit/tracks/video-track.test.js | 56 +-- test/unit/tracks/video-tracks.test.js | 26 +- test/unit/utils/dom.test.js | 178 +++---- test/unit/utils/fn.test.js | 4 +- test/unit/utils/format-time.test.js | 44 +- test/unit/utils/log.test.js | 22 +- test/unit/utils/merge-options.test.js | 4 +- test/unit/utils/time-ranges.test.js | 16 +- test/unit/utils/to-title-case.test.js | 4 +- test/unit/utils/url.test.js | 78 +-- test/unit/video.test.js | 84 ++-- 45 files changed, 1701 insertions(+), 1700 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb8ca6a8f..01b20bda8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ CHANGELOG * @BrandonOCasey updated language docs to link to IANA language registry ([view](https://github.com/videojs/video.js/pull/3493)) * @gkatsev removed unused dependencies ([view](https://github.com/videojs/video.js/pull/3516)) * @misteroneill enabled and updated videojs-standard and fixed an issue with linting ([view](https://github.com/videojs/video.js/pull/3508)) +* @misteroneill updated tests to qunit 2.0 ([view](https://github.com/videojs/video.js/pull/3509)) -------------------- diff --git a/package.json b/package.json index f184cff349..3d32b6e5ea 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "karma-sinon": "^1.0.5", "load-grunt-tasks": "^3.1.0", "proxyquireify": "^3.0.0", - "qunitjs": "^1.18.0", + "qunitjs": "^2.0.1", "sinon": "^1.16.1", "time-grunt": "^1.1.1", "uglify-js": "~2.3.6", diff --git a/test/api/api.js b/test/api/api.js index 37a59a20e7..62eb735b35 100644 --- a/test/api/api.js +++ b/test/api/api.js @@ -8,75 +8,75 @@ import window from 'global/window'; const videojs = window.videojs; QUnit.module('Player API'); -QUnit.test('videojs should exist on the window', function() { - QUnit.ok(window.videojs, 'videojs exists on the window'); +QUnit.test('videojs should exist on the window', function(assert) { + assert.ok(window.videojs, 'videojs exists on the window'); }); -QUnit.test('should be able to access expected player API methods', function() { +QUnit.test('should be able to access expected player API methods', function(assert) { const player = videojs.getComponent('Player').prototype; // Native HTML5 Methods - QUnit.ok(player.error, 'error exists'); - QUnit.ok(player.src, 'src exists'); - QUnit.ok(player.currentSrc, 'currentSrc exists'); - QUnit.ok(player.buffered, 'buffered exists'); - QUnit.ok(player.load, 'load exists'); - QUnit.ok(player.seeking, 'seeking exists'); - QUnit.ok(player.currentTime, 'currentTime exists'); - QUnit.ok(player.duration, 'duration exists'); - QUnit.ok(player.paused, 'paused exists'); - QUnit.ok(player.ended, 'ended exists'); - QUnit.ok(player.autoplay, 'autoplay exists'); - QUnit.ok(player.loop, 'loop exists'); - QUnit.ok(player.play, 'play exists'); - QUnit.ok(player.pause, 'pause exists'); - QUnit.ok(player.controls, 'controls exists'); - QUnit.ok(player.volume, 'volume exists'); - QUnit.ok(player.muted, 'muted exists'); - QUnit.ok(player.width, 'width exists'); - QUnit.ok(player.height, 'height exists'); - QUnit.ok(player.poster, 'poster exists'); - QUnit.ok(player.textTracks, 'textTracks exists'); - QUnit.ok(player.requestFullscreen, 'requestFullscreen exists'); - QUnit.ok(player.exitFullscreen, 'exitFullscreen exists'); - QUnit.ok(player.playbackRate, 'playbackRate exists'); - QUnit.ok(player.networkState, 'networkState exists'); - QUnit.ok(player.readyState, 'readyState exists'); + assert.ok(player.error, 'error exists'); + assert.ok(player.src, 'src exists'); + assert.ok(player.currentSrc, 'currentSrc exists'); + assert.ok(player.buffered, 'buffered exists'); + assert.ok(player.load, 'load exists'); + assert.ok(player.seeking, 'seeking exists'); + assert.ok(player.currentTime, 'currentTime exists'); + assert.ok(player.duration, 'duration exists'); + assert.ok(player.paused, 'paused exists'); + assert.ok(player.ended, 'ended exists'); + assert.ok(player.autoplay, 'autoplay exists'); + assert.ok(player.loop, 'loop exists'); + assert.ok(player.play, 'play exists'); + assert.ok(player.pause, 'pause exists'); + assert.ok(player.controls, 'controls exists'); + assert.ok(player.volume, 'volume exists'); + assert.ok(player.muted, 'muted exists'); + assert.ok(player.width, 'width exists'); + assert.ok(player.height, 'height exists'); + assert.ok(player.poster, 'poster exists'); + assert.ok(player.textTracks, 'textTracks exists'); + assert.ok(player.requestFullscreen, 'requestFullscreen exists'); + assert.ok(player.exitFullscreen, 'exitFullscreen exists'); + assert.ok(player.playbackRate, 'playbackRate exists'); + assert.ok(player.networkState, 'networkState exists'); + assert.ok(player.readyState, 'readyState exists'); // Unsupported Native HTML5 Methods - // QUnit.ok(player.canPlayType, 'canPlayType exists'); - // QUnit.ok(player.startTime, 'startTime exists'); - // QUnit.ok(player.defaultPlaybackRate, 'defaultPlaybackRate exists'); - // QUnit.ok(player.playbackRate, 'playbackRate exists'); - // QUnit.ok(player.played, 'played exists'); - // QUnit.ok(player.seekable, 'seekable exists'); - // QUnit.ok(player.videoWidth, 'videoWidth exists'); - // QUnit.ok(player.videoHeight, 'videoHeight exists'); + // assert.ok(player.canPlayType, 'canPlayType exists'); + // assert.ok(player.startTime, 'startTime exists'); + // assert.ok(player.defaultPlaybackRate, 'defaultPlaybackRate exists'); + // assert.ok(player.playbackRate, 'playbackRate exists'); + // assert.ok(player.played, 'played exists'); + // assert.ok(player.seekable, 'seekable exists'); + // assert.ok(player.videoWidth, 'videoWidth exists'); + // assert.ok(player.videoHeight, 'videoHeight exists'); // Additional player methods - QUnit.ok(player.bufferedPercent, 'bufferedPercent exists'); - QUnit.ok(player.reportUserActivity, 'reportUserActivity exists'); - QUnit.ok(player.userActive, 'userActive exists'); - QUnit.ok(player.usingNativeControls, 'usingNativeControls exists'); - QUnit.ok(player.isFullscreen, 'isFullscreen exists'); + assert.ok(player.bufferedPercent, 'bufferedPercent exists'); + assert.ok(player.reportUserActivity, 'reportUserActivity exists'); + assert.ok(player.userActive, 'userActive exists'); + assert.ok(player.usingNativeControls, 'usingNativeControls exists'); + assert.ok(player.isFullscreen, 'isFullscreen exists'); // Track methods - QUnit.ok(player.audioTracks, 'audioTracks exists'); - QUnit.ok(player.videoTracks, 'videoTracks exists'); - QUnit.ok(player.textTracks, 'textTracks exists'); - QUnit.ok(player.remoteTextTrackEls, 'remoteTextTrackEls exists'); - QUnit.ok(player.remoteTextTracks, 'remoteTextTracks exists'); - QUnit.ok(player.addTextTrack, 'addTextTrack exists'); - QUnit.ok(player.addRemoteTextTrack, 'addRemoteTextTrack exists'); - QUnit.ok(player.removeRemoteTextTrack, 'removeRemoteTextTrack exists'); + assert.ok(player.audioTracks, 'audioTracks exists'); + assert.ok(player.videoTracks, 'videoTracks exists'); + assert.ok(player.textTracks, 'textTracks exists'); + assert.ok(player.remoteTextTrackEls, 'remoteTextTrackEls exists'); + assert.ok(player.remoteTextTracks, 'remoteTextTracks exists'); + assert.ok(player.addTextTrack, 'addTextTrack exists'); + assert.ok(player.addRemoteTextTrack, 'addRemoteTextTrack exists'); + assert.ok(player.removeRemoteTextTrack, 'removeRemoteTextTrack exists'); // Deprecated methods that should still exist - QUnit.ok(player.requestFullScreen, 'requestFullScreen exists'); - QUnit.ok(player.isFullScreen, 'isFullScreen exists'); - QUnit.ok(player.cancelFullScreen, 'cancelFullScreen exists'); + assert.ok(player.requestFullScreen, 'requestFullScreen exists'); + assert.ok(player.isFullScreen, 'isFullScreen exists'); + assert.ok(player.cancelFullScreen, 'cancelFullScreen exists'); }); -QUnit.test('should be able to access expected component API methods', function() { +QUnit.test('should be able to access expected component API methods', function(assert) { const Component = videojs.getComponent('Component'); const comp = new Component({ id() { @@ -86,40 +86,40 @@ QUnit.test('should be able to access expected component API methods', function() }); // Component methods - QUnit.ok(comp.player, 'player exists'); - QUnit.ok(comp.options, 'options exists'); - QUnit.ok(comp.init, 'init exists'); - QUnit.ok(comp.dispose, 'dispose exists'); - QUnit.ok(comp.createEl, 'createEl exists'); - QUnit.ok(comp.contentEl, 'contentEl exists'); - QUnit.ok(comp.el, 'el exists'); - QUnit.ok(comp.addChild, 'addChild exists'); - QUnit.ok(comp.getChild, 'getChild exists'); - QUnit.ok(comp.getChildById, 'getChildById exists'); - QUnit.ok(comp.children, 'children exists'); - QUnit.ok(comp.initChildren, 'initChildren exists'); - QUnit.ok(comp.removeChild, 'removeChild exists'); - QUnit.ok(comp.on, 'on exists'); - QUnit.ok(comp.off, 'off exists'); - QUnit.ok(comp.one, 'one exists'); - QUnit.ok(comp.trigger, 'trigger exists'); - QUnit.ok(comp.triggerReady, 'triggerReady exists'); - QUnit.ok(comp.show, 'show exists'); - QUnit.ok(comp.hide, 'hide exists'); - QUnit.ok(comp.width, 'width exists'); - QUnit.ok(comp.height, 'height exists'); - QUnit.ok(comp.dimensions, 'dimensions exists'); - QUnit.ok(comp.ready, 'ready exists'); - QUnit.ok(comp.addClass, 'addClass exists'); - QUnit.ok(comp.removeClass, 'removeClass exists'); - QUnit.ok(comp.buildCSSClass, 'buildCSSClass exists'); - QUnit.ok(comp.setInterval, 'setInterval exists'); - QUnit.ok(comp.clearInterval, 'clearInterval exists'); - QUnit.ok(comp.setTimeout, 'setTimeout exists'); - QUnit.ok(comp.clearTimeout, 'clearTimeout exists'); + assert.ok(comp.player, 'player exists'); + assert.ok(comp.options, 'options exists'); + assert.ok(comp.init, 'init exists'); + assert.ok(comp.dispose, 'dispose exists'); + assert.ok(comp.createEl, 'createEl exists'); + assert.ok(comp.contentEl, 'contentEl exists'); + assert.ok(comp.el, 'el exists'); + assert.ok(comp.addChild, 'addChild exists'); + assert.ok(comp.getChild, 'getChild exists'); + assert.ok(comp.getChildById, 'getChildById exists'); + assert.ok(comp.children, 'children exists'); + assert.ok(comp.initChildren, 'initChildren exists'); + assert.ok(comp.removeChild, 'removeChild exists'); + assert.ok(comp.on, 'on exists'); + assert.ok(comp.off, 'off exists'); + assert.ok(comp.one, 'one exists'); + assert.ok(comp.trigger, 'trigger exists'); + assert.ok(comp.triggerReady, 'triggerReady exists'); + assert.ok(comp.show, 'show exists'); + assert.ok(comp.hide, 'hide exists'); + assert.ok(comp.width, 'width exists'); + assert.ok(comp.height, 'height exists'); + assert.ok(comp.dimensions, 'dimensions exists'); + assert.ok(comp.ready, 'ready exists'); + assert.ok(comp.addClass, 'addClass exists'); + assert.ok(comp.removeClass, 'removeClass exists'); + assert.ok(comp.buildCSSClass, 'buildCSSClass exists'); + assert.ok(comp.setInterval, 'setInterval exists'); + assert.ok(comp.clearInterval, 'clearInterval exists'); + assert.ok(comp.setTimeout, 'setTimeout exists'); + assert.ok(comp.clearTimeout, 'clearTimeout exists'); }); -QUnit.test('should be able to access expected MediaTech API methods', function() { +QUnit.test('should be able to access expected MediaTech API methods', function(assert) { const media = videojs.getComponent('Tech'); const mediaProto = media.prototype; const html5 = videojs.getComponent('Html5'); @@ -127,32 +127,32 @@ QUnit.test('should be able to access expected MediaTech API methods', function() const flash = videojs.getComponent('Flash'); const flashProto = flash.prototype; - QUnit.ok(mediaProto.setPoster, 'setPoster should exist on the Media tech'); - QUnit.ok(html5Proto.setPoster, 'setPoster should exist on the HTML5 tech'); - QUnit.ok(flashProto.setPoster, 'setPoster should exist on the Flash tech'); + assert.ok(mediaProto.setPoster, 'setPoster should exist on the Media tech'); + assert.ok(html5Proto.setPoster, 'setPoster should exist on the HTML5 tech'); + assert.ok(flashProto.setPoster, 'setPoster should exist on the Flash tech'); - QUnit.ok(html5.patchCanPlayType, 'patchCanPlayType should exist for HTML5'); - QUnit.ok(html5.unpatchCanPlayType, 'unpatchCanPlayType should exist for HTML5'); + assert.ok(html5.patchCanPlayType, 'patchCanPlayType should exist for HTML5'); + assert.ok(html5.unpatchCanPlayType, 'unpatchCanPlayType should exist for HTML5'); // Source Handler Functions - QUnit.ok(media.withSourceHandlers, 'withSourceHandlers should exist for Media Tech'); + assert.ok(media.withSourceHandlers, 'withSourceHandlers should exist for Media Tech'); - QUnit.ok(html5.canPlaySource, 'canPlaySource should exist for HTML5'); - QUnit.ok(html5.registerSourceHandler, 'registerSourceHandler should exist for Html5'); - QUnit.ok(html5.selectSourceHandler, 'selectSourceHandler should exist for Html5'); - QUnit.ok(html5.prototype.setSource, 'setSource should exist for Html5'); - QUnit.ok(html5.prototype.disposeSourceHandler, + assert.ok(html5.canPlaySource, 'canPlaySource should exist for HTML5'); + assert.ok(html5.registerSourceHandler, 'registerSourceHandler should exist for Html5'); + assert.ok(html5.selectSourceHandler, 'selectSourceHandler should exist for Html5'); + assert.ok(html5.prototype.setSource, 'setSource should exist for Html5'); + assert.ok(html5.prototype.disposeSourceHandler, 'disposeSourceHandler should exist for Html5'); - QUnit.ok(flash.canPlaySource, 'canPlaySource should exist for Flash'); - QUnit.ok(flash.registerSourceHandler, 'registerSourceHandler should exist for Flash'); - QUnit.ok(flash.selectSourceHandler, 'selectSourceHandler should exist for Flash'); - QUnit.ok(flash.prototype.setSource, 'setSource should exist for Flash'); - QUnit.ok(flash.prototype.disposeSourceHandler, + assert.ok(flash.canPlaySource, 'canPlaySource should exist for Flash'); + assert.ok(flash.registerSourceHandler, 'registerSourceHandler should exist for Flash'); + assert.ok(flash.selectSourceHandler, 'selectSourceHandler should exist for Flash'); + assert.ok(flash.prototype.setSource, 'setSource should exist for Flash'); + assert.ok(flash.prototype.disposeSourceHandler, 'disposeSourceHandler should exist for Flash'); }); -QUnit.test('should export ready api call to public', function() { +QUnit.test('should export ready api call to public', function(assert) { const videoTag = testHelperMakeTag(); const fixture = document.getElementById('qunit-fixture'); @@ -160,62 +160,62 @@ QUnit.test('should export ready api call to public', function() { const player = videojs('example_1'); - QUnit.ok(player.ready !== undefined, 'ready callback is defined'); + assert.ok(player.ready !== undefined, 'ready callback is defined'); player.dispose(); }); -QUnit.test('should export useful components to the public', function() { - QUnit.ok(videojs.browser.TOUCH_ENABLED !== undefined, +QUnit.test('should export useful components to the public', function(assert) { + assert.ok(videojs.browser.TOUCH_ENABLED !== undefined, 'Touch detection should be public'); - QUnit.ok(videojs.getComponent('ControlBar'), 'ControlBar should be public'); - QUnit.ok(videojs.getComponent('Button'), 'Button should be public'); - QUnit.ok(videojs.getComponent('PlayToggle'), 'PlayToggle should be public'); - QUnit.ok(videojs.getComponent('FullscreenToggle'), 'FullscreenToggle should be public'); - QUnit.ok(videojs.getComponent('BigPlayButton'), 'BigPlayButton should be public'); - QUnit.ok(videojs.getComponent('LoadingSpinner'), 'LoadingSpinner should be public'); - QUnit.ok(videojs.getComponent('CurrentTimeDisplay'), + assert.ok(videojs.getComponent('ControlBar'), 'ControlBar should be public'); + assert.ok(videojs.getComponent('Button'), 'Button should be public'); + assert.ok(videojs.getComponent('PlayToggle'), 'PlayToggle should be public'); + assert.ok(videojs.getComponent('FullscreenToggle'), 'FullscreenToggle should be public'); + assert.ok(videojs.getComponent('BigPlayButton'), 'BigPlayButton should be public'); + assert.ok(videojs.getComponent('LoadingSpinner'), 'LoadingSpinner should be public'); + assert.ok(videojs.getComponent('CurrentTimeDisplay'), 'CurrentTimeDisplay should be public'); - QUnit.ok(videojs.getComponent('DurationDisplay'), 'DurationDisplay should be public'); - QUnit.ok(videojs.getComponent('TimeDivider'), 'TimeDivider should be public'); - QUnit.ok(videojs.getComponent('RemainingTimeDisplay'), + assert.ok(videojs.getComponent('DurationDisplay'), 'DurationDisplay should be public'); + assert.ok(videojs.getComponent('TimeDivider'), 'TimeDivider should be public'); + assert.ok(videojs.getComponent('RemainingTimeDisplay'), 'RemainingTimeDisplay should be public'); - QUnit.ok(videojs.getComponent('Slider'), 'Slider should be public'); - QUnit.ok(videojs.getComponent('ProgressControl'), 'ProgressControl should be public'); - QUnit.ok(videojs.getComponent('SeekBar'), 'SeekBar should be public'); - QUnit.ok(videojs.getComponent('LoadProgressBar'), 'LoadProgressBar should be public'); - QUnit.ok(videojs.getComponent('PlayProgressBar'), 'PlayProgressBar should be public'); - QUnit.ok(videojs.getComponent('VolumeControl'), 'VolumeControl should be public'); - QUnit.ok(videojs.getComponent('VolumeBar'), 'VolumeBar should be public'); - QUnit.ok(videojs.getComponent('VolumeLevel'), 'VolumeLevel should be public'); - QUnit.ok(videojs.getComponent('VolumeMenuButton'), 'VolumeMenuButton should be public'); - QUnit.ok(videojs.getComponent('MuteToggle'), 'MuteToggle should be public'); - QUnit.ok(videojs.getComponent('PosterImage'), 'PosterImage should be public'); - QUnit.ok(videojs.getComponent('Menu'), 'Menu should be public'); - QUnit.ok(videojs.getComponent('MenuItem'), 'MenuItem should be public'); - QUnit.ok(videojs.getComponent('MenuButton'), 'MenuButton should be public'); - QUnit.ok(videojs.getComponent('PlaybackRateMenuButton'), + assert.ok(videojs.getComponent('Slider'), 'Slider should be public'); + assert.ok(videojs.getComponent('ProgressControl'), 'ProgressControl should be public'); + assert.ok(videojs.getComponent('SeekBar'), 'SeekBar should be public'); + assert.ok(videojs.getComponent('LoadProgressBar'), 'LoadProgressBar should be public'); + assert.ok(videojs.getComponent('PlayProgressBar'), 'PlayProgressBar should be public'); + assert.ok(videojs.getComponent('VolumeControl'), 'VolumeControl should be public'); + assert.ok(videojs.getComponent('VolumeBar'), 'VolumeBar should be public'); + assert.ok(videojs.getComponent('VolumeLevel'), 'VolumeLevel should be public'); + assert.ok(videojs.getComponent('VolumeMenuButton'), 'VolumeMenuButton should be public'); + assert.ok(videojs.getComponent('MuteToggle'), 'MuteToggle should be public'); + assert.ok(videojs.getComponent('PosterImage'), 'PosterImage should be public'); + assert.ok(videojs.getComponent('Menu'), 'Menu should be public'); + assert.ok(videojs.getComponent('MenuItem'), 'MenuItem should be public'); + assert.ok(videojs.getComponent('MenuButton'), 'MenuButton should be public'); + assert.ok(videojs.getComponent('PlaybackRateMenuButton'), 'PlaybackRateMenuButton should be public'); - QUnit.ok(videojs.getComponent('CaptionSettingsMenuItem'), + assert.ok(videojs.getComponent('CaptionSettingsMenuItem'), 'CaptionSettingsMenuItem should be public'); - QUnit.ok(videojs.getComponent('OffTextTrackMenuItem'), + assert.ok(videojs.getComponent('OffTextTrackMenuItem'), 'OffTextTrackMenuItem should be public'); - QUnit.ok(videojs.getComponent('TextTrackMenuItem'), + assert.ok(videojs.getComponent('TextTrackMenuItem'), 'TextTrackMenuItem should be public'); - QUnit.ok(videojs.getComponent('TextTrackDisplay'), 'TextTrackDisplay should be public'); - QUnit.ok(videojs.getComponent('TextTrackButton'), 'TextTrackButton should be public'); - QUnit.ok(videojs.getComponent('CaptionsButton'), 'CaptionsButton should be public'); - QUnit.ok(videojs.getComponent('SubtitlesButton'), 'SubtitlesButton should be public'); - QUnit.ok(videojs.getComponent('DescriptionsButton'), + assert.ok(videojs.getComponent('TextTrackDisplay'), 'TextTrackDisplay should be public'); + assert.ok(videojs.getComponent('TextTrackButton'), 'TextTrackButton should be public'); + assert.ok(videojs.getComponent('CaptionsButton'), 'CaptionsButton should be public'); + assert.ok(videojs.getComponent('SubtitlesButton'), 'SubtitlesButton should be public'); + assert.ok(videojs.getComponent('DescriptionsButton'), 'DescriptionsButton should be public'); - QUnit.ok(videojs.getComponent('ChaptersButton'), 'ChaptersButton should be public'); - QUnit.ok(videojs.getComponent('ChaptersTrackMenuItem'), + assert.ok(videojs.getComponent('ChaptersButton'), 'ChaptersButton should be public'); + assert.ok(videojs.getComponent('ChaptersTrackMenuItem'), 'ChaptersTrackMenuItem should be public'); - QUnit.ok(videojs.mergeOptions, 'mergeOptions should be public'); + assert.ok(videojs.mergeOptions, 'mergeOptions should be public'); }); -QUnit.test('should be able to initialize player twice on the same tag using string reference', function() { +QUnit.test('should be able to initialize player twice on the same tag using string reference', function(assert) { const videoTag = testHelperMakeTag(); const id = videoTag.id; const fixture = document.getElementById('qunit-fixture'); @@ -225,7 +225,7 @@ QUnit.test('should be able to initialize player twice on the same tag using stri const player = videojs('example_1'); player.dispose(); - QUnit.ok(!document.getElementById(id), 'element is removed'); + assert.ok(!document.getElementById(id), 'element is removed'); videoTag = testHelperMakeTag(); fixture.appendChild(videoTag); @@ -234,7 +234,7 @@ QUnit.test('should be able to initialize player twice on the same tag using stri player.dispose(); }); -QUnit.test('videojs.getPlayers() should be available after minification', function() { +QUnit.test('videojs.getPlayers() should be available after minification', function(assert) { const videoTag = testHelperMakeTag(); const id = videoTag.id; const fixture = document.getElementById('qunit-fixture'); @@ -243,12 +243,12 @@ QUnit.test('videojs.getPlayers() should be available after minification', functi const player = videojs(id); - QUnit.ok(videojs.getPlayers()[id] === player, 'videojs.getPlayers() is available'); + assert.ok(videojs.getPlayers()[id] === player, 'videojs.getPlayers() is available'); player.dispose(); }); -QUnit.test('component can be subclassed externally', function() { +QUnit.test('component can be subclassed externally', function(assert) { const Component = videojs.getComponent('Component'); const ControlBar = videojs.getComponent('ControlBar'); @@ -265,7 +265,7 @@ QUnit.test('component can be subclassed externally', function() { reportUserActivity() {} }); - QUnit.ok(new ControlBar(player), 'created a control bar without throwing'); + assert.ok(new ControlBar(player), 'created a control bar without throwing'); }); function testHelperMakeTag() { @@ -276,7 +276,7 @@ function testHelperMakeTag() { return videoTag; } -QUnit.test('should extend Component', function() { +QUnit.test('should extend Component', function(assert) { const Component = videojs.getComponent('Component'); const MyComponent = videojs.extend(Component, { constructor() { @@ -289,13 +289,13 @@ QUnit.test('should extend Component', function() { const myComponent = new MyComponent(); - QUnit.ok(myComponent instanceof Component, 'creates an instance of Component'); - QUnit.ok(myComponent instanceof MyComponent, 'creates an instance of MyComponent'); - QUnit.ok(myComponent.bar, 'the constructor function is used'); - QUnit.ok(myComponent.foo(), 'instance methods are applied'); + assert.ok(myComponent instanceof Component, 'creates an instance of Component'); + assert.ok(myComponent instanceof MyComponent, 'creates an instance of MyComponent'); + assert.ok(myComponent.bar, 'the constructor function is used'); + assert.ok(myComponent.foo(), 'instance methods are applied'); const NoMethods = videojs.extend(Component); const noMethods = new NoMethods({}); - QUnit.ok(noMethods.on, 'should extend component with no methods or constructor'); + assert.ok(noMethods.on, 'should extend component with no methods or constructor'); }); diff --git a/test/unit/button.test.js b/test/unit/button.test.js index d5e82a9a6e..021bf6c427 100644 --- a/test/unit/button.test.js +++ b/test/unit/button.test.js @@ -4,8 +4,8 @@ import TestHelpers from './test-helpers.js'; QUnit.module('Button'); -QUnit.test('should localize its text', function() { - QUnit.expect(3); +QUnit.test('should localize its text', function(assert) { + assert.expect(3); const player = TestHelpers.makePlayer({ language: 'es', @@ -21,7 +21,7 @@ QUnit.test('should localize its text', function() { testButton.controlText_ = 'Play'; const el = testButton.createEl(); - QUnit.ok(el.nodeName.toLowerCase().match('button')); - QUnit.ok(el.innerHTML.match(/vjs-control-text"?>Juego/)); - QUnit.equal(el.getAttribute('title'), 'Juego'); + assert.ok(el.nodeName.toLowerCase().match('button')); + assert.ok(el.innerHTML.match(/vjs-control-text"?>Juego/)); + assert.equal(el.getAttribute('title'), 'Juego'); }); diff --git a/test/unit/clickable-component.test.js b/test/unit/clickable-component.test.js index 322acb6883..191ac4bf20 100644 --- a/test/unit/clickable-component.test.js +++ b/test/unit/clickable-component.test.js @@ -4,37 +4,37 @@ import TestHelpers from './test-helpers.js'; QUnit.module('ClickableComponent'); -QUnit.test('should create a div with role="button"', function() { - QUnit.expect(2); +QUnit.test('should create a div with role="button"', function(assert) { + assert.expect(2); const player = TestHelpers.makePlayer({}); const testClickableComponent = new ClickableComponent(player); const el = testClickableComponent.createEl(); - QUnit.equal(el.nodeName.toLowerCase(), 'div', 'the name of the element is "div"'); - QUnit.equal(el.getAttribute('role').toLowerCase(), 'button', 'the role of the element is "button"'); + assert.equal(el.nodeName.toLowerCase(), 'div', 'the name of the element is "div"'); + assert.equal(el.getAttribute('role').toLowerCase(), 'button', 'the role of the element is "button"'); testClickableComponent.dispose(); player.dispose(); }); -QUnit.test('should be enabled/disabled', function() { - QUnit.expect(3); +QUnit.test('should be enabled/disabled', function(assert) { + assert.expect(3); const player = TestHelpers.makePlayer({}); const testClickableComponent = new ClickableComponent(player); - QUnit.equal(testClickableComponent.hasClass('vjs-disabled'), false, 'ClickableComponent defaults to enabled'); + assert.equal(testClickableComponent.hasClass('vjs-disabled'), false, 'ClickableComponent defaults to enabled'); testClickableComponent.disable(); - QUnit.equal(testClickableComponent.hasClass('vjs-disabled'), true, 'ClickableComponent is disabled'); + assert.equal(testClickableComponent.hasClass('vjs-disabled'), true, 'ClickableComponent is disabled'); testClickableComponent.enable(); - QUnit.equal(testClickableComponent.hasClass('vjs-disabled'), false, 'ClickableComponent is enabled'); + assert.equal(testClickableComponent.hasClass('vjs-disabled'), false, 'ClickableComponent is enabled'); testClickableComponent.dispose(); player.dispose(); diff --git a/test/unit/component.test.js b/test/unit/component.test.js index 2dc5ac8b41..a1d502146e 100644 --- a/test/unit/component.test.js +++ b/test/unit/component.test.js @@ -23,10 +23,10 @@ Component.registerComponent('TestComponent3', TestComponent3); Component.registerComponent('TestComponent4', TestComponent4); QUnit.module('Component', { - setup() { + beforeEach() { this.clock = sinon.useFakeTimers(); }, - teardown() { + afterEach() { this.clock.restore(); } }); @@ -41,76 +41,76 @@ const getFakePlayer = function() { }; }; -QUnit.test('should create an element', function() { +QUnit.test('should create an element', function(assert) { const comp = new Component(getFakePlayer(), {}); - QUnit.ok(comp.el().nodeName); + assert.ok(comp.el().nodeName); }); -QUnit.test('should add a child component', function() { +QUnit.test('should add a child component', function(assert) { const comp = new Component(getFakePlayer()); const child = comp.addChild('component'); - QUnit.ok(comp.children().length === 1); - QUnit.ok(comp.children()[0] === child); - QUnit.ok(comp.el().childNodes[0] === child.el()); - QUnit.ok(comp.getChild('component') === child); - QUnit.ok(comp.getChildById(child.id()) === child); + assert.ok(comp.children().length === 1); + assert.ok(comp.children()[0] === child); + assert.ok(comp.el().childNodes[0] === child.el()); + assert.ok(comp.getChild('component') === child); + assert.ok(comp.getChildById(child.id()) === child); }); -QUnit.test('should add a child component to an index', function() { +QUnit.test('should add a child component to an index', function(assert) { const comp = new Component(getFakePlayer()); const child = comp.addChild('component'); - QUnit.ok(comp.children().length === 1); - QUnit.ok(comp.children()[0] === child); + assert.ok(comp.children().length === 1); + assert.ok(comp.children()[0] === child); const child0 = comp.addChild('component', {}, 0); - QUnit.ok(comp.children().length === 2); - QUnit.ok(comp.children()[0] === child0); - QUnit.ok(comp.children()[1] === child); + assert.ok(comp.children().length === 2); + assert.ok(comp.children()[0] === child0); + assert.ok(comp.children()[1] === child); const child1 = comp.addChild('component', {}, '2'); - QUnit.ok(comp.children().length === 3); - QUnit.ok(comp.children()[2] === child1); + assert.ok(comp.children().length === 3); + assert.ok(comp.children()[2] === child1); const child2 = comp.addChild('component', {}, undefined); - QUnit.ok(comp.children().length === 4); - QUnit.ok(comp.children()[3] === child2); + assert.ok(comp.children().length === 4); + assert.ok(comp.children()[3] === child2); const child3 = comp.addChild('component', {}, -1); - QUnit.ok(comp.children().length === 5); - QUnit.ok(comp.children()[3] === child3); - QUnit.ok(comp.children()[4] === child2); + assert.ok(comp.children().length === 5); + assert.ok(comp.children()[3] === child3); + assert.ok(comp.children()[4] === child2); }); -QUnit.test('addChild should throw if the child does not exist', function() { +QUnit.test('addChild should throw if the child does not exist', function(assert) { const comp = new Component(getFakePlayer()); - throws(function() { + assert.throws(function() { comp.addChild('non-existent-child'); }, new Error('Component Non-existent-child does not exist'), 'addChild threw'); }); -QUnit.test('should init child components from options', function() { +QUnit.test('should init child components from options', function(assert) { const comp = new Component(getFakePlayer(), { children: { component: {} } }); - QUnit.ok(comp.children().length === 1); - QUnit.ok(comp.el().childNodes.length === 1); + assert.ok(comp.children().length === 1); + assert.ok(comp.el().childNodes.length === 1); }); -QUnit.test('should init child components from simple children array', function() { +QUnit.test('should init child components from simple children array', function(assert) { const comp = new Component(getFakePlayer(), { children: [ 'component', @@ -119,11 +119,11 @@ QUnit.test('should init child components from simple children array', function() ] }); - QUnit.ok(comp.children().length === 3); - QUnit.ok(comp.el().childNodes.length === 3); + assert.ok(comp.children().length === 3); + assert.ok(comp.el().childNodes.length === 3); }); -QUnit.test('should init child components from children array of objects', function() { +QUnit.test('should init child components from children array of objects', function(assert) { const comp = new Component(getFakePlayer(), { children: [ { name: 'component' }, @@ -132,11 +132,11 @@ QUnit.test('should init child components from children array of objects', functi ] }); - QUnit.ok(comp.children().length === 3); - QUnit.ok(comp.el().childNodes.length === 3); + assert.ok(comp.children().length === 3); + assert.ok(comp.el().childNodes.length === 3); }); -QUnit.test('should do a deep merge of child options', function() { +QUnit.test('should do a deep merge of child options', function(assert) { // Create a default option for component Component.prototype.options_ = { example: { @@ -157,31 +157,32 @@ QUnit.test('should do a deep merge of child options', function() { const mergedOptions = comp.options_; const children = mergedOptions.example; - QUnit.strictEqual(children.childOne.foo, 'baz', 'value three levels deep overridden'); - QUnit.strictEqual(children.childOne.asdf, 'fdsa', 'value three levels deep maintained'); - QUnit.strictEqual(children.childOne.abc, '123', 'value three levels deep added'); - QUnit.ok(children.childTwo, 'object two levels deep maintained'); - QUnit.strictEqual(children.childThree, false, 'object two levels deep removed'); - QUnit.ok(children.childFour, 'object two levels deep added'); + assert.strictEqual(children.childOne.foo, 'baz', 'value three levels deep overridden'); + assert.strictEqual(children.childOne.asdf, 'fdsa', 'value three levels deep maintained'); + assert.strictEqual(children.childOne.abc, '123', 'value three levels deep added'); + assert.ok(children.childTwo, 'object two levels deep maintained'); + assert.strictEqual(children.childThree, false, 'object two levels deep removed'); + assert.ok(children.childFour, 'object two levels deep added'); - QUnit.strictEqual(Component.prototype.options_.example.childOne.foo, 'bar', - 'prototype options were not overridden'); + assert.strictEqual(Component.prototype.options_.example.childOne.foo, + 'bar', + 'prototype options were not overridden'); // Reset default component options to none Component.prototype.options_ = null; }); -QUnit.test('should init child components from component options', function() { +QUnit.test('should init child components from component options', function(assert) { const testComp = new TestComponent1(TestHelpers.makePlayer(), { testComponent2: false, testComponent4: {} }); - QUnit.ok(!testComp.childNameIndex_.testComponent2, 'we do not have testComponent2'); - QUnit.ok(testComp.childNameIndex_.testComponent4, 'we have a testComponent4'); + assert.ok(!testComp.childNameIndex_.testComponent2, 'we do not have testComponent2'); + assert.ok(testComp.childNameIndex_.testComponent4, 'we have a testComponent4'); }); -QUnit.test('should allows setting child options at the parent options level', function() { +QUnit.test('should allows setting child options at the parent options level', function(assert) { let parent; // using children array @@ -200,10 +201,10 @@ QUnit.test('should allows setting child options at the parent options level', fu try { parent = new Component(getFakePlayer(), options); } catch (err) { - QUnit.ok(false, 'Child with `false` option was initialized'); + assert.ok(false, 'Child with `false` option was initialized'); } - QUnit.equal(parent.children()[0].options_.foo, true, 'child options set when children array is used'); - QUnit.equal(parent.children().length, 1, 'we should only have one child'); + assert.equal(parent.children()[0].options_.foo, true, 'child options set when children array is used'); + assert.equal(parent.children().length, 1, 'we should only have one child'); // using children object options = { @@ -223,19 +224,19 @@ QUnit.test('should allows setting child options at the parent options level', fu try { parent = new Component(getFakePlayer(), options); } catch (err) { - QUnit.ok(false, 'Child with `false` option was initialized'); + assert.ok(false, 'Child with `false` option was initialized'); } - QUnit.equal(parent.children()[0].options_.foo, true, 'child options set when children object is used'); - QUnit.equal(parent.children().length, 1, 'we should only have one child'); + assert.equal(parent.children()[0].options_.foo, true, 'child options set when children object is used'); + assert.equal(parent.children().length, 1, 'we should only have one child'); }); -QUnit.test('should dispose of component and children', function() { +QUnit.test('should dispose of component and children', function(assert) { const comp = new Component(getFakePlayer()); // Add a child const child = comp.addChild('Component'); - QUnit.ok(comp.children().length === 1); + assert.ok(comp.children().length === 1); // Add a listener comp.on('click', function() { @@ -254,28 +255,28 @@ QUnit.test('should dispose of component and children', function() { comp.dispose(); - QUnit.ok(hasDisposed, 'component fired dispose event'); - QUnit.ok(bubbles === false, 'dispose event does not bubble'); - QUnit.ok(!comp.children(), 'component children were deleted'); - QUnit.ok(!comp.el(), 'component element was deleted'); - QUnit.ok(!child.children(), 'child children were deleted'); - QUnit.ok(!child.el(), 'child element was deleted'); - QUnit.ok(!Dom.hasElData(el), 'listener data nulled'); - QUnit.ok(!Object.getOwnPropertyNames(data).length, + assert.ok(hasDisposed, 'component fired dispose event'); + assert.ok(bubbles === false, 'dispose event does not bubble'); + assert.ok(!comp.children(), 'component children were deleted'); + assert.ok(!comp.el(), 'component element was deleted'); + assert.ok(!child.children(), 'child children were deleted'); + assert.ok(!child.el(), 'child element was deleted'); + assert.ok(!Dom.hasElData(el), 'listener data nulled'); + assert.ok(!Object.getOwnPropertyNames(data).length, 'original listener data object was emptied'); }); -QUnit.test('should add and remove event listeners to element', function() { +QUnit.test('should add and remove event listeners to element', function(assert) { const comp = new Component(getFakePlayer(), {}); // No need to make this async because we're triggering events inline. // We're going to trigger the event after removing the listener, // So if we get extra asserts that's a problem. - QUnit.expect(2); + assert.expect(2); const testListener = function() { - QUnit.ok(true, 'fired event once'); - QUnit.ok(this === comp, 'listener has the component as context'); + assert.ok(true, 'fired event once'); + assert.ok(this === comp, 'listener has the component as context'); }; comp.on('test-event', testListener); @@ -284,13 +285,13 @@ QUnit.test('should add and remove event listeners to element', function() { comp.trigger('test-event'); }); -QUnit.test('should trigger a listener once using one()', function() { +QUnit.test('should trigger a listener once using one()', function(assert) { const comp = new Component(getFakePlayer(), {}); - QUnit.expect(1); + assert.expect(1); const testListener = function() { - QUnit.ok(true, 'fired event once'); + assert.ok(true, 'fired event once'); }; comp.one('test-event', testListener); @@ -298,17 +299,17 @@ QUnit.test('should trigger a listener once using one()', function() { comp.trigger('test-event'); }); -QUnit.test('should be possible to pass data when you trigger an event', function() { +QUnit.test('should be possible to pass data when you trigger an event', function(assert) { const comp = new Component(getFakePlayer(), {}); const data1 = 'Data1'; const data2 = {txt: 'Data2'}; - QUnit.expect(3); + assert.expect(3); const testListener = function(evt, hash) { - QUnit.ok(true, 'fired event once'); - deepEqual(hash.d1, data1); - deepEqual(hash.d2, data2); + assert.ok(true, 'fired event once'); + assert.deepEqual(hash.d1, data1); + assert.deepEqual(hash.d2, data2); }; comp.one('test-event', testListener); @@ -316,47 +317,47 @@ QUnit.test('should be possible to pass data when you trigger an event', function comp.trigger('test-event'); }); -QUnit.test('should add listeners to other components and remove them', function() { +QUnit.test('should add listeners to other components and remove them', function(assert) { const player = getFakePlayer(); const comp1 = new Component(player); const comp2 = new Component(player); let listenerFired = 0; const testListener = function() { - QUnit.equal(this, comp1, 'listener has the first component as context'); + assert.equal(this, comp1, 'listener has the first component as context'); listenerFired++; }; comp1.on(comp2, 'test-event', testListener); comp2.trigger('test-event'); - QUnit.equal(listenerFired, 1, 'listener was fired once'); + assert.equal(listenerFired, 1, 'listener was fired once'); listenerFired = 0; comp1.off(comp2, 'test-event', testListener); comp2.trigger('test-event'); - QUnit.equal(listenerFired, 0, 'listener was not fired after being removed'); + assert.equal(listenerFired, 0, 'listener was not fired after being removed'); // this component is disposed first listenerFired = 0; comp1.on(comp2, 'test-event', testListener); comp1.dispose(); comp2.trigger('test-event'); - QUnit.equal(listenerFired, 0, 'listener was removed when this component was disposed first'); + assert.equal(listenerFired, 0, 'listener was removed when this component was disposed first'); comp1.off = function() { throw new Error('Comp1 off called'); }; comp2.dispose(); - QUnit.ok(true, 'this component removed dispose listeners from other component'); + assert.ok(true, 'this component removed dispose listeners from other component'); }); -QUnit.test('should add listeners to other components and remove when them other component is disposed', function() { +QUnit.test('should add listeners to other components and remove when them other component is disposed', function(assert) { const player = getFakePlayer(); const comp1 = new Component(player); const comp2 = new Component(player); let listenerFired = 0; const testListener = function() { - QUnit.equal(this, comp1, 'listener has the first component as context'); + assert.equal(this, comp1, 'listener has the first component as context'); listenerFired++; }; @@ -366,53 +367,53 @@ QUnit.test('should add listeners to other components and remove when them other throw new Error('Comp2 off called'); }; comp1.dispose(); - QUnit.ok(true, 'this component removed dispose listener from this component that referenced other component'); + assert.ok(true, 'this component removed dispose listener from this component that referenced other component'); }); -QUnit.test('should add listeners to other components that are fired once', function() { +QUnit.test('should add listeners to other components that are fired once', function(assert) { const player = getFakePlayer(); const comp1 = new Component(player); const comp2 = new Component(player); let listenerFired = 0; const testListener = function() { - QUnit.equal(this, comp1, 'listener has the first component as context'); + assert.equal(this, comp1, 'listener has the first component as context'); listenerFired++; }; comp1.one(comp2, 'test-event', testListener); comp2.trigger('test-event'); - QUnit.equal(listenerFired, 1, 'listener was executed once'); + assert.equal(listenerFired, 1, 'listener was executed once'); comp2.trigger('test-event'); - QUnit.equal(listenerFired, 1, 'listener was executed only once'); + assert.equal(listenerFired, 1, 'listener was executed only once'); }); -QUnit.test('should add listeners to other element and remove them', function() { +QUnit.test('should add listeners to other element and remove them', function(assert) { const player = getFakePlayer(); const comp1 = new Component(player); const el = document.createElement('div'); let listenerFired = 0; const testListener = function() { - QUnit.equal(this, comp1, 'listener has the first component as context'); + assert.equal(this, comp1, 'listener has the first component as context'); listenerFired++; }; comp1.on(el, 'test-event', testListener); Events.trigger(el, 'test-event'); - QUnit.equal(listenerFired, 1, 'listener was fired once'); + assert.equal(listenerFired, 1, 'listener was fired once'); listenerFired = 0; comp1.off(el, 'test-event', testListener); Events.trigger(el, 'test-event'); - QUnit.equal(listenerFired, 0, 'listener was not fired after being removed from other element'); + assert.equal(listenerFired, 0, 'listener was not fired after being removed from other element'); // this component is disposed first listenerFired = 0; comp1.on(el, 'test-event', testListener); comp1.dispose(); Events.trigger(el, 'test-event'); - QUnit.equal(listenerFired, 0, 'listener was removed when this component was disposed first'); + assert.equal(listenerFired, 0, 'listener was removed when this component was disposed first'); comp1.off = function() { throw new Error('Comp1 off called'); }; @@ -420,31 +421,31 @@ QUnit.test('should add listeners to other element and remove them', function() { try { Events.trigger(el, 'dispose'); } catch (e) { - QUnit.ok(false, 'listener was not removed from other element'); + assert.ok(false, 'listener was not removed from other element'); } Events.trigger(el, 'dispose'); - QUnit.ok(true, 'this component removed dispose listeners from other element'); + assert.ok(true, 'this component removed dispose listeners from other element'); }); -QUnit.test('should add listeners to other components that are fired once', function() { +QUnit.test('should add listeners to other components that are fired once', function(assert) { const player = getFakePlayer(); const comp1 = new Component(player); const el = document.createElement('div'); let listenerFired = 0; const testListener = function() { - QUnit.equal(this, comp1, 'listener has the first component as context'); + assert.equal(this, comp1, 'listener has the first component as context'); listenerFired++; }; comp1.one(el, 'test-event', testListener); Events.trigger(el, 'test-event'); - QUnit.equal(listenerFired, 1, 'listener was executed once'); + assert.equal(listenerFired, 1, 'listener was executed once'); Events.trigger(el, 'test-event'); - QUnit.equal(listenerFired, 1, 'listener was executed only once'); + assert.equal(listenerFired, 1, 'listener was executed only once'); }); -QUnit.test('should trigger a listener when ready', function() { +QUnit.test('should trigger a listener when ready', function(assert) { let initListenerFired; let methodListenerFired; let syncListenerFired; @@ -463,13 +464,13 @@ QUnit.test('should trigger a listener when ready', function() { syncListenerFired = true; }, true); - QUnit.ok(!initListenerFired, 'init listener should NOT fire synchronously'); - QUnit.ok(!methodListenerFired, 'method listener should NOT fire synchronously'); - QUnit.ok(syncListenerFired, 'sync listener SHOULD fire synchronously if after ready'); + assert.ok(!initListenerFired, 'init listener should NOT fire synchronously'); + assert.ok(!methodListenerFired, 'method listener should NOT fire synchronously'); + assert.ok(syncListenerFired, 'sync listener SHOULD fire synchronously if after ready'); this.clock.tick(1); - QUnit.ok(initListenerFired, 'init listener should fire asynchronously'); - QUnit.ok(methodListenerFired, 'method listener should fire asynchronously'); + assert.ok(initListenerFired, 'init listener should fire asynchronously'); + assert.ok(methodListenerFired, 'method listener should fire asynchronously'); // Listeners should only be fired once and then removed initListenerFired = false; @@ -479,12 +480,12 @@ QUnit.test('should trigger a listener when ready', function() { comp.triggerReady(); this.clock.tick(1); - QUnit.ok(!initListenerFired, 'init listener should be removed'); - QUnit.ok(!methodListenerFired, 'method listener should be removed'); - QUnit.ok(!syncListenerFired, 'sync listener should be removed'); + assert.ok(!initListenerFired, 'init listener should be removed'); + assert.ok(!methodListenerFired, 'method listener should be removed'); + assert.ok(!syncListenerFired, 'sync listener should be removed'); }); -QUnit.test('should not retrigger a listener when the listener calls triggerReady', function() { +QUnit.test('should not retrigger a listener when the listener calls triggerReady', function(assert) { let timesCalled = 0; let selfTriggered = false; const comp = new Component(getFakePlayer(), {}); @@ -505,32 +506,32 @@ QUnit.test('should not retrigger a listener when the listener calls triggerReady this.clock.tick(100); - QUnit.equal(timesCalled, 1, 'triggerReady from inside a ready handler does not result in an infinite loop'); + assert.equal(timesCalled, 1, 'triggerReady from inside a ready handler does not result in an infinite loop'); }); -QUnit.test('should add and remove a CSS class', function() { +QUnit.test('should add and remove a CSS class', function(assert) { const comp = new Component(getFakePlayer(), {}); comp.addClass('test-class'); - QUnit.ok(comp.el().className.indexOf('test-class') !== -1); + assert.ok(comp.el().className.indexOf('test-class') !== -1); comp.removeClass('test-class'); - QUnit.ok(comp.el().className.indexOf('test-class') === -1); + assert.ok(comp.el().className.indexOf('test-class') === -1); comp.toggleClass('test-class'); - QUnit.ok(comp.el().className.indexOf('test-class') !== -1); + assert.ok(comp.el().className.indexOf('test-class') !== -1); comp.toggleClass('test-class'); - QUnit.ok(comp.el().className.indexOf('test-class') === -1); + assert.ok(comp.el().className.indexOf('test-class') === -1); }); -QUnit.test('should show and hide an element', function() { +QUnit.test('should show and hide an element', function(assert) { const comp = new Component(getFakePlayer(), {}); comp.hide(); - QUnit.ok(comp.hasClass('vjs-hidden') === true); + assert.ok(comp.hasClass('vjs-hidden') === true); comp.show(); - QUnit.ok(comp.hasClass('vjs-hidden') === false); + assert.ok(comp.hasClass('vjs-hidden') === false); }); -QUnit.test('dimension() should treat NaN and null as zero', function() { +QUnit.test('dimension() should treat NaN and null as zero', function(assert) { let newWidth; const width = 300; @@ -543,23 +544,23 @@ QUnit.test('dimension() should treat NaN and null as zero', function() { newWidth = comp.dimension('width', null); - QUnit.notEqual(newWidth, width, 'new width and old width are not the same'); - QUnit.equal(newWidth, comp, 'we set a value, so, return value is component'); - QUnit.equal(comp.width(), 0, 'the new width is zero'); + assert.notEqual(newWidth, width, 'new width and old width are not the same'); + assert.equal(newWidth, comp, 'we set a value, so, return value is component'); + assert.equal(comp.width(), 0, 'the new width is zero'); const newHeight = comp.dimension('height', NaN); - QUnit.notEqual(newHeight, height, 'new height and old height are not the same'); - QUnit.equal(newHeight, comp, 'we set a value, so, return value is component'); - QUnit.equal(comp.height(), 0, 'the new height is zero'); + assert.notEqual(newHeight, height, 'new height and old height are not the same'); + assert.equal(newHeight, comp, 'we set a value, so, return value is component'); + assert.equal(comp.height(), 0, 'the new height is zero'); comp.width(width); newWidth = comp.dimension('width', undefined); - QUnit.equal(newWidth, width, 'we did not set the width with undefined'); + assert.equal(newWidth, width, 'we did not set the width with undefined'); }); -QUnit.test('should change the width and height of a component', function() { +QUnit.test('should change the width and height of a component', function(assert) { const container = document.createElement('div'); const comp = new Component(getFakePlayer(), {}); const el = comp.el(); @@ -574,22 +575,22 @@ QUnit.test('should change the width and height of a component', function() { comp.width('50%'); comp.height('123px'); - QUnit.ok(comp.width() === 500, 'percent values working'); + assert.ok(comp.width() === 500, 'percent values working'); const compStyle = TestHelpers.getComputedStyle(el, 'width'); - QUnit.ok(compStyle === comp.width() + 'px', 'matches computed style'); - QUnit.ok(comp.height() === 123, 'px values working'); + assert.ok(compStyle === comp.width() + 'px', 'matches computed style'); + assert.ok(comp.height() === 123, 'px values working'); comp.width(321); - QUnit.ok(comp.width() === 321, 'integer values working'); + assert.ok(comp.width() === 321, 'integer values working'); comp.width('auto'); comp.height('auto'); - QUnit.ok(comp.width() === 1000, 'forced width was removed'); - QUnit.ok(comp.height() === 0, 'forced height was removed'); + assert.ok(comp.width() === 1000, 'forced width was removed'); + assert.ok(comp.height() === 0, 'forced height was removed'); }); -QUnit.test('should get the computed dimensions', function() { +QUnit.test('should get the computed dimensions', function(assert) { const container = document.createElement('div'); const comp = new Component(getFakePlayer(), {}); const el = comp.el(); @@ -607,18 +608,18 @@ QUnit.test('should get the computed dimensions', function() { comp.width('50%'); comp.height('50%'); - QUnit.equal(comp.currentWidth() + 'px', computedWidth, 'matches computed width'); - QUnit.equal(comp.currentHeight() + 'px', computedHeight, 'matches computed height'); + assert.equal(comp.currentWidth() + 'px', computedWidth, 'matches computed width'); + assert.equal(comp.currentHeight() + 'px', computedHeight, 'matches computed height'); - QUnit.equal(comp.currentDimension('width') + 'px', computedWidth, 'matches computed width'); - QUnit.equal(comp.currentDimension('height') + 'px', computedHeight, 'matches computed height'); + assert.equal(comp.currentDimension('width') + 'px', computedWidth, 'matches computed width'); + assert.equal(comp.currentDimension('height') + 'px', computedHeight, 'matches computed height'); - QUnit.equal(comp.currentDimensions().width + 'px', computedWidth, 'matches computed width'); - QUnit.equal(comp.currentDimensions().height + 'px', computedHeight, 'matches computed width'); + assert.equal(comp.currentDimensions().width + 'px', computedWidth, 'matches computed width'); + assert.equal(comp.currentDimensions().height + 'px', computedHeight, 'matches computed width'); }); -QUnit.test('should use a defined content el for appending children', function() { +QUnit.test('should use a defined content el for appending children', function(assert) { class CompWithContent extends Component {} CompWithContent.prototype.createEl = function() { @@ -634,30 +635,30 @@ QUnit.test('should use a defined content el for appending children', function() const comp = new CompWithContent(getFakePlayer()); const child = comp.addChild('component'); - QUnit.ok(comp.children().length === 1); - QUnit.ok(comp.el().childNodes[0].id === 'contentEl'); - QUnit.ok(comp.el().childNodes[0].childNodes[0] === child.el()); + assert.ok(comp.children().length === 1); + assert.ok(comp.el().childNodes[0].id === 'contentEl'); + assert.ok(comp.el().childNodes[0].childNodes[0] === child.el()); comp.removeChild(child); - QUnit.ok(comp.children().length === 0, 'Length should now be zero'); - QUnit.ok(comp.el().childNodes[0].id === 'contentEl', 'Content El should still exist'); - QUnit.ok(comp.el().childNodes[0].childNodes[0] !== child.el(), + assert.ok(comp.children().length === 0, 'Length should now be zero'); + assert.ok(comp.el().childNodes[0].id === 'contentEl', 'Content El should still exist'); + assert.ok(comp.el().childNodes[0].childNodes[0] !== child.el(), 'Child el should be removed.'); }); -QUnit.test('should emit a tap event', function() { +QUnit.test('should emit a tap event', function(assert) { const comp = new Component(getFakePlayer()); let singleTouch = {}; const origTouch = browser.TOUCH_ENABLED; - QUnit.expect(3); + assert.expect(3); // Fake touch support. Real touch support isn't needed for this test. browser.TOUCH_ENABLED = true; comp.emitTapEvents(); comp.on('tap', function() { - QUnit.ok(true, 'Tap event emitted'); + assert.ok(true, 'Tap event emitted'); }); // A touchstart followed by touchend should trigger a tap @@ -704,30 +705,30 @@ QUnit.test('should emit a tap event', function() { browser.TOUCH_ENABLED = origTouch; }); -QUnit.test('should provide timeout methods that automatically get cleared on component disposal', function() { +QUnit.test('should provide timeout methods that automatically get cleared on component disposal', function(assert) { const comp = new Component(getFakePlayer()); let timeoutsFired = 0; const timeoutToClear = comp.setTimeout(function() { timeoutsFired++; - QUnit.ok(false, 'Timeout should have been manually cleared'); + assert.ok(false, 'Timeout should have been manually cleared'); }, 500); - QUnit.expect(4); + assert.expect(4); comp.setTimeout(function() { timeoutsFired++; - QUnit.equal(this, comp, 'Timeout fn has the component as its context'); - QUnit.ok(true, 'Timeout created and fired.'); + assert.equal(this, comp, 'Timeout fn has the component as its context'); + assert.ok(true, 'Timeout created and fired.'); }, 100); comp.setTimeout(function() { timeoutsFired++; - QUnit.ok(false, 'Timeout should have been disposed'); + assert.ok(false, 'Timeout should have been disposed'); }, 1000); this.clock.tick(100); - QUnit.ok(timeoutsFired === 1, 'One timeout should have fired by this point'); + assert.ok(timeoutsFired === 1, 'One timeout should have fired by this point'); comp.clearTimeout(timeoutToClear); @@ -737,45 +738,45 @@ QUnit.test('should provide timeout methods that automatically get cleared on com this.clock.tick(1000); - QUnit.ok(timeoutsFired === 1, 'One timeout should have fired overall'); + assert.ok(timeoutsFired === 1, 'One timeout should have fired overall'); }); -QUnit.test('should provide interval methods that automatically get cleared on component disposal', function() { +QUnit.test('should provide interval methods that automatically get cleared on component disposal', function(assert) { const comp = new Component(getFakePlayer()); let intervalsFired = 0; const interval = comp.setInterval(function() { intervalsFired++; - QUnit.equal(this, comp, 'Interval fn has the component as its context'); - QUnit.ok(true, 'Interval created and fired.'); + assert.equal(this, comp, 'Interval fn has the component as its context'); + assert.ok(true, 'Interval created and fired.'); }, 100); - QUnit.expect(13); + assert.expect(13); comp.setInterval(function() { intervalsFired++; - QUnit.ok(false, 'Interval should have been disposed'); + assert.ok(false, 'Interval should have been disposed'); }, 1200); this.clock.tick(500); - QUnit.ok(intervalsFired === 5, 'Component interval fired 5 times'); + assert.ok(intervalsFired === 5, 'Component interval fired 5 times'); comp.clearInterval(interval); this.clock.tick(600); - QUnit.ok(intervalsFired === 5, 'Interval was manually cleared'); + assert.ok(intervalsFired === 5, 'Interval was manually cleared'); comp.dispose(); this.clock.tick(1200); - QUnit.ok(intervalsFired === 5, 'Interval was cleared when component was disposed'); + assert.ok(intervalsFired === 5, 'Interval was cleared when component was disposed'); }); -QUnit.test('$ and $$ functions', function() { +QUnit.test('$ and $$ functions', function(assert) { const comp = new Component(getFakePlayer()); const contentEl = document.createElement('div'); const children = [ @@ -786,6 +787,6 @@ QUnit.test('$ and $$ functions', function() { comp.contentEl_ = contentEl; children.forEach(child => contentEl.appendChild(child)); - QUnit.strictEqual(comp.$('div'), children[0], '$ defaults to contentEl as scope'); - QUnit.strictEqual(comp.$$('div').length, children.length, '$$ defaults to contentEl as scope'); + assert.strictEqual(comp.$('div'), children[0], '$ defaults to contentEl as scope'); + assert.strictEqual(comp.$$('div').length, children.length, '$$ defaults to contentEl as scope'); }); diff --git a/test/unit/controls.test.js b/test/unit/controls.test.js index e2a8efc2fc..5b173310dc 100644 --- a/test/unit/controls.test.js +++ b/test/unit/controls.test.js @@ -8,8 +8,8 @@ import document from 'global/document'; QUnit.module('Controls'); -QUnit.test('should hide volume control if it\'s not supported', function() { - QUnit.expect(2); +QUnit.test('should hide volume control if it\'s not supported', function(assert) { + assert.expect(2); const noop = function() {}; const player = { id: noop, @@ -26,11 +26,11 @@ QUnit.test('should hide volume control if it\'s not supported', function() { const volumeControl = new VolumeControl(player); const muteToggle = new MuteToggle(player); - QUnit.ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0, 'volumeControl is not hidden'); - QUnit.ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0, 'muteToggle is not hidden'); + assert.ok(volumeControl.el().className.indexOf('vjs-hidden') >= 0, 'volumeControl is not hidden'); + assert.ok(muteToggle.el().className.indexOf('vjs-hidden') >= 0, 'muteToggle is not hidden'); }); -QUnit.test('should test and toggle volume control on `loadstart`', function() { +QUnit.test('should test and toggle volume control on `loadstart`', function(assert) { const noop = function() {}; const listeners = []; const player = { @@ -57,27 +57,27 @@ QUnit.test('should test and toggle volume control on `loadstart`', function() { const volumeControl = new VolumeControl(player); const muteToggle = new MuteToggle(player); - QUnit.equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl is hidden initially'); - QUnit.equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle is hidden initially'); + assert.equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl is hidden initially'); + assert.equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle is hidden initially'); player.tech_.featuresVolumeControl = false; for (let i = 0; i < listeners.length; i++) { listeners[i](); } - QUnit.equal(volumeControl.hasClass('vjs-hidden'), true, 'volumeControl does not hide itself'); - QUnit.equal(muteToggle.hasClass('vjs-hidden'), true, 'muteToggle does not hide itself'); + assert.equal(volumeControl.hasClass('vjs-hidden'), true, 'volumeControl does not hide itself'); + assert.equal(muteToggle.hasClass('vjs-hidden'), true, 'muteToggle does not hide itself'); player.tech_.featuresVolumeControl = true; for (let i = 0; i < listeners.length; i++) { listeners[i](); } - QUnit.equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl does not show itself'); - QUnit.equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle does not show itself'); + assert.equal(volumeControl.hasClass('vjs-hidden'), false, 'volumeControl does not show itself'); + assert.equal(muteToggle.hasClass('vjs-hidden'), false, 'muteToggle does not show itself'); }); -QUnit.test('calculateDistance should use changedTouches, if available', function() { +QUnit.test('calculateDistance should use changedTouches, if available', function(assert) { const noop = function() {}; const player = { id: noop, @@ -99,14 +99,14 @@ QUnit.test('calculateDistance should use changedTouches, if available', function }] }; - QUnit.equal(slider.calculateDistance(event), 0.5, 'we should have touched exactly in the center, so, the ratio should be half'); + assert.equal(slider.calculateDistance(event), 0.5, 'we should have touched exactly in the center, so, the ratio should be half'); }); -QUnit.test('should hide playback rate control if it\'s not supported', function() { - QUnit.expect(1); +QUnit.test('should hide playback rate control if it\'s not supported', function(assert) { + assert.expect(1); const player = TestHelpers.makePlayer(); const playbackRate = new PlaybackRateMenuButton(player); - QUnit.ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden'); + assert.ok(playbackRate.el().className.indexOf('vjs-hidden') >= 0, 'playbackRate is not hidden'); }); diff --git a/test/unit/events.test.js b/test/unit/events.test.js index 1f1add911e..f0d926cecd 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -4,12 +4,12 @@ import document from 'global/document'; QUnit.module('Events'); -QUnit.test('should add and remove an event listener to an element', function() { - QUnit.expect(1); +QUnit.test('should add and remove an event listener to an element', function(assert) { + assert.expect(1); const el = document.createElement('div'); const listener = function() { - QUnit.ok(true, 'Click Triggered'); + assert.ok(true, 'Click Triggered'); }; Events.on(el, 'click', listener); @@ -20,12 +20,12 @@ QUnit.test('should add and remove an event listener to an element', function() { Events.trigger(el, 'click'); }); -QUnit.test('should add and remove multiple event listeners to an element with a single call', function() { - QUnit.expect(6); +QUnit.test('should add and remove multiple event listeners to an element with a single call', function(assert) { + assert.expect(6); const el = document.createElement('div'); const listener = function() { - QUnit.ok(true, 'Callback triggered'); + assert.ok(true, 'Callback triggered'); }; Events.on(el, ['click', 'event1', 'event2'], listener); @@ -49,16 +49,16 @@ QUnit.test('should add and remove multiple event listeners to an element with a Events.trigger(el, 'event2'); }); -QUnit.test('should be possible to pass data when you trigger an event', function() { - QUnit.expect(6); +QUnit.test('should be possible to pass data when you trigger an event', function(assert) { + assert.expect(6); const el = document.createElement('div'); const fakeData1 = 'Fake Data 1'; const fakeData2 = {txt: 'Fake Data 2'}; const listener = function(evt, hash) { - QUnit.ok(true, 'Callback triggered'); - deepEqual(fakeData1, hash.d1, 'Shoulbe be passed to the handler'); - deepEqual(fakeData2, hash.d2, 'Shoulbe be passed to the handler'); + assert.ok(true, 'Callback triggered'); + assert.deepEqual(fakeData1, hash.d1, 'Shoulbe be passed to the handler'); + assert.deepEqual(fakeData2, hash.d2, 'Shoulbe be passed to the handler'); }; Events.on(el, ['event1', 'event2'], listener); @@ -67,7 +67,7 @@ QUnit.test('should be possible to pass data when you trigger an event', function }); -QUnit.test('should remove all listeners of a type', function() { +QUnit.test('should remove all listeners of a type', function(assert) { const el = document.createElement('div'); let clicks = 0; const listener = function() { @@ -82,16 +82,16 @@ QUnit.test('should remove all listeners of a type', function() { // 2 clicks Events.trigger(el, 'click'); - QUnit.ok(clicks === 2, 'both click listeners fired'); + assert.ok(clicks === 2, 'both click listeners fired'); Events.off(el, 'click'); // No click should happen. Events.trigger(el, 'click'); - QUnit.ok(clicks === 2, 'no click listeners fired'); + assert.ok(clicks === 2, 'no click listeners fired'); }); -QUnit.test('should remove all listeners of an array of types', function() { +QUnit.test('should remove all listeners of an array of types', function(assert) { const el = document.createElement('div'); let calls = 0; const listener = function() { @@ -108,7 +108,7 @@ QUnit.test('should remove all listeners of an array of types', function() { // 2 calls Events.trigger(el, 'event1'); - QUnit.ok(calls === 4, 'both click listeners fired'); + assert.ok(calls === 4, 'both click listeners fired'); Events.off(el, ['click', 'event1']); // No click should happen. @@ -116,18 +116,18 @@ QUnit.test('should remove all listeners of an array of types', function() { // No event1 should happen. Events.trigger(el, 'event1'); - QUnit.ok(calls === 4, 'no event listeners fired'); + assert.ok(calls === 4, 'no event listeners fired'); }); -QUnit.test('should remove all listeners from an element', function() { - QUnit.expect(2); +QUnit.test('should remove all listeners from an element', function(assert) { + assert.expect(2); const el = document.createElement('div'); const listener = function() { - QUnit.ok(true, 'Fake1 Triggered'); + assert.ok(true, 'Fake1 Triggered'); }; const listener2 = function() { - QUnit.ok(true, 'Fake2 Triggered'); + assert.ok(true, 'Fake2 Triggered'); }; Events.on(el, 'fake1', listener); @@ -143,12 +143,12 @@ QUnit.test('should remove all listeners from an element', function() { Events.trigger(el, 'fake2'); }); -QUnit.test('should listen only once', function() { - QUnit.expect(1); +QUnit.test('should listen only once', function(assert) { + assert.expect(1); const el = document.createElement('div'); const listener = function() { - QUnit.ok(true, 'Click Triggered'); + assert.ok(true, 'Click Triggered'); }; Events.one(el, 'click', listener); @@ -158,12 +158,12 @@ QUnit.test('should listen only once', function() { Events.trigger(el, 'click'); }); -QUnit.test('should listen only once in multiple events from a single call', function() { - QUnit.expect(3); +QUnit.test('should listen only once in multiple events from a single call', function(assert) { + assert.expect(3); const el = document.createElement('div'); const listener = function() { - QUnit.ok(true, 'Callback Triggered'); + assert.ok(true, 'Callback Triggered'); }; Events.one(el, ['click', 'event1', 'event2'], listener); @@ -181,80 +181,80 @@ QUnit.test('should listen only once in multiple events from a single call', func Events.trigger(el, 'event2'); }); -QUnit.test('should stop immediate propagtion', function() { - QUnit.expect(1); +QUnit.test('should stop immediate propagtion', function(assert) { + assert.expect(1); const el = document.createElement('div'); Events.on(el, 'test', function(e) { - QUnit.ok(true, 'First listener fired'); + assert.ok(true, 'First listener fired'); e.stopImmediatePropagation(); }); Events.on(el, 'test', function(e) { - QUnit.ok(false, 'Second listener fired'); + assert.ok(false, 'Second listener fired'); }); Events.trigger(el, 'test'); }); -QUnit.test('should bubble up DOM unless bubbles == false', function() { - QUnit.expect(3); +QUnit.test('should bubble up DOM unless bubbles == false', function(assert) { + assert.expect(3); const outer = document.createElement('div'); const inner = outer.appendChild(document.createElement('div')); // Verify that if bubbles === true, event bubbles up dom. Events.on(inner, 'bubbles', function(e) { - QUnit.ok(true, 'Inner listener fired'); + assert.ok(true, 'Inner listener fired'); }); Events.on(outer, 'bubbles', function(e) { - QUnit.ok(true, 'Outer listener fired'); + assert.ok(true, 'Outer listener fired'); }); Events.trigger(inner, { type: 'bubbles', target: inner, bubbles: true }); // Only change 'bubbles' to false, and verify only inner handler is called. Events.on(inner, 'nobub', function(e) { - QUnit.ok(true, 'Inner listener fired'); + assert.ok(true, 'Inner listener fired'); }); Events.on(outer, 'nobub', function(e) { - QUnit.ok(false, 'Outer listener fired'); + assert.ok(false, 'Outer listener fired'); }); Events.trigger(inner, { type: 'nobub', target: inner, bubbles: false }); }); -QUnit.test('should have a defaultPrevented property on an event that was prevent from doing default action', function() { - QUnit.expect(2); +QUnit.test('should have a defaultPrevented property on an event that was prevent from doing default action', function(assert) { + assert.expect(2); const el = document.createElement('div'); Events.on(el, 'test', function(e) { - QUnit.ok(true, 'First listener fired'); + assert.ok(true, 'First listener fired'); e.preventDefault(); }); Events.on(el, 'test', function(e) { - QUnit.ok(e.defaultPrevented, 'Should have `defaultPrevented` to signify preventDefault being called'); + assert.ok(e.defaultPrevented, 'Should have `defaultPrevented` to signify preventDefault being called'); }); Events.trigger(el, 'test'); }); -QUnit.test('should have relatedTarget correctly set on the event', function() { - QUnit.expect(2); +QUnit.test('should have relatedTarget correctly set on the event', function(assert) { + assert.expect(2); const el1 = document.createElement('div'); const el2 = document.createElement('div'); const relatedEl = document.createElement('div'); Events.on(el1, 'click', function(e) { - QUnit.equal(e.relatedTarget, relatedEl, 'relatedTarget is set for all browsers when related element is set on the event'); + assert.equal(e.relatedTarget, relatedEl, 'relatedTarget is set for all browsers when related element is set on the event'); }); Events.trigger(el1, { type: 'click', relatedTarget: relatedEl }); Events.on(el2, 'click', function(e) { - QUnit.equal(e.relatedTarget, null, 'relatedTarget is null when none is provided'); + assert.equal(e.relatedTarget, null, 'relatedTarget is null when none is provided'); }); Events.trigger(el2, { type: 'click', relatedTarget: undefined }); diff --git a/test/unit/extend.test.js b/test/unit/extend.test.js index 3b5c7da469..cbc7f9d1ea 100644 --- a/test/unit/extend.test.js +++ b/test/unit/extend.test.js @@ -3,7 +3,7 @@ import extendFn from '../../src/js/extend.js'; QUnit.module('extend.js'); -QUnit.test('should add implicit parent constructor call', function() { +QUnit.test('should add implicit parent constructor call', function(assert) { let superCalled = false; const Parent = function() { superCalled = true; @@ -13,6 +13,6 @@ QUnit.test('should add implicit parent constructor call', function() { }); const child = new Child(); - QUnit.ok(superCalled, 'super constructor called'); - QUnit.ok(child.foo, 'child properties set'); + assert.ok(superCalled, 'super constructor called'); + assert.ok(child.foo, 'child properties set'); }); diff --git a/test/unit/menu.test.js b/test/unit/menu.test.js index 12ec097f07..41f60c2128 100644 --- a/test/unit/menu.test.js +++ b/test/unit/menu.test.js @@ -5,8 +5,8 @@ import * as Events from '../../src/js/utils/events.js'; QUnit.module('MenuButton'); -QUnit.test('should not throw an error when there is no children', function() { - QUnit.expect(0); +QUnit.test('should not throw an error when there is no children', function(assert) { + assert.expect(0); const player = TestHelpers.makePlayer(); const menuButton = new MenuButton(player); @@ -15,13 +15,13 @@ QUnit.test('should not throw an error when there is no children', function() { try { Events.trigger(el, 'click'); } catch (error) { - QUnit.ok(!error, 'click should not throw anything'); + assert.ok(!error, 'click should not throw anything'); } player.dispose(); }); -QUnit.test('should place title list item into ul', function() { +QUnit.test('should place title list item into ul', function(assert) { const player = TestHelpers.makePlayer(); const menuButton = new MenuButton(player, { @@ -31,13 +31,13 @@ QUnit.test('should place title list item into ul', function() { const menuContentElement = menuButton.el().getElementsByTagName('UL')[0]; const titleElement = menuContentElement.children[0]; - QUnit.ok(titleElement.innerHTML === 'TestTitle', 'title element placed in ul'); + assert.ok(titleElement.innerHTML === 'TestTitle', 'title element placed in ul'); player.dispose(); }); -QUnit.test('clicking should display the menu', function() { - QUnit.expect(6); +QUnit.test('clicking should display the menu', function(assert) { + assert.expect(6); const player = TestHelpers.makePlayer(); @@ -47,29 +47,29 @@ QUnit.test('clicking should display the menu', function() { }); const el = menuButton.el(); - QUnit.ok(menuButton.menu !== undefined, 'menu is created'); + assert.ok(menuButton.menu !== undefined, 'menu is created'); - QUnit.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'menu defaults to hidden'); + assert.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'menu defaults to hidden'); Events.trigger(el, 'click'); - QUnit.equal(menuButton.menu.hasClass('vjs-lock-showing'), true, 'clicking on the menu button shows the menu'); + assert.equal(menuButton.menu.hasClass('vjs-lock-showing'), true, 'clicking on the menu button shows the menu'); Events.trigger(el, 'click'); - QUnit.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'clicking again on the menu button hides the menu'); + assert.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'clicking again on the menu button hides the menu'); menuButton.disable(); Events.trigger(el, 'click'); - QUnit.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'disable() prevents clicking from showing the menu'); + assert.equal(menuButton.menu.hasClass('vjs-lock-showing'), false, 'disable() prevents clicking from showing the menu'); menuButton.enable(); Events.trigger(el, 'click'); - QUnit.equal(menuButton.menu.hasClass('vjs-lock-showing'), true, 'enable() allows clicking to show the menu'); + assert.equal(menuButton.menu.hasClass('vjs-lock-showing'), true, 'enable() allows clicking to show the menu'); player.dispose(); }); diff --git a/test/unit/player.test.js b/test/unit/player.test.js index 6dc5af6933..7e72387e52 100644 --- a/test/unit/player.test.js +++ b/test/unit/player.test.js @@ -14,38 +14,38 @@ import Tech from '../../src/js/tech/tech.js'; import TechFaker from './tech/tech-faker.js'; QUnit.module('Player', { - setup() { + beforeEach() { this.clock = sinon.useFakeTimers(); }, - teardown() { + afterEach() { this.clock.restore(); } }); -QUnit.test('should create player instance that inherits from component and dispose it', function() { +QUnit.test('should create player instance that inherits from component and dispose it', function(assert) { const player = TestHelpers.makePlayer(); - QUnit.ok(player.el().nodeName === 'DIV'); - QUnit.ok(player.on, 'component function exists'); + assert.ok(player.el().nodeName === 'DIV'); + assert.ok(player.on, 'component function exists'); player.dispose(); - QUnit.ok(player.el() === null, 'element disposed'); + assert.ok(player.el() === null, 'element disposed'); }); -QUnit.test('dispose should not throw if styleEl is missing', function() { +QUnit.test('dispose should not throw if styleEl is missing', function(assert) { const player = TestHelpers.makePlayer(); player.styleEl_.parentNode.removeChild(player.styleEl_); player.dispose(); - QUnit.ok(player.el() === null, 'element disposed'); + assert.ok(player.el() === null, 'element disposed'); }); // technically, all uses of videojs.options should be replaced with // Player.prototype.options_ in this file and a equivalent test using // videojs.options should be made in video.test.js. Keeping this here // until we make that move. -QUnit.test('should accept options from multiple sources and override in correct order', function() { +QUnit.test('should accept options from multiple sources and override in correct order', function(assert) { // Set a global option videojs.options.attr = 1; @@ -53,7 +53,7 @@ QUnit.test('should accept options from multiple sources and override in correct const tag0 = TestHelpers.makeTag(); const player0 = new Player(tag0, { techOrder: ['techFaker'] }); - QUnit.equal(player0.options_.attr, 1, 'global option was set'); + assert.equal(player0.options_.attr, 1, 'global option was set'); player0.dispose(); // Set a tag level option @@ -64,7 +64,7 @@ QUnit.test('should accept options from multiple sources and override in correct const player2 = new Player(tag2, { techOrder: ['techFaker'] }); - QUnit.equal(player2.options_.attr, 'asdf', 'Tag options overrode global options'); + assert.equal(player2.options_.attr, 'asdf', 'Tag options overrode global options'); player2.dispose(); // Set a tag level option @@ -74,11 +74,11 @@ QUnit.test('should accept options from multiple sources and override in correct const player3 = new Player(tag3, { techOrder: ['techFaker'], attr: 'fdsa' }); - QUnit.equal(player3.options_.attr, 'fdsa', 'Init options overrode tag and global options'); + assert.equal(player3.options_.attr, 'fdsa', 'Init options overrode tag and global options'); player3.dispose(); }); -QUnit.test('should get tag, source, and track settings', function() { +QUnit.test('should get tag, source, and track settings', function(assert) { // Partially tested in lib->getElAttributes const fixture = document.getElementById('qunit-fixture'); @@ -95,33 +95,33 @@ QUnit.test('should get tag, source, and track settings', function() { const tag = document.getElementById('example_1'); const player = TestHelpers.makePlayer({}, tag); - QUnit.equal(player.options_.autoplay, true, 'autoplay is set to true'); - QUnit.equal(player.options_.preload, 'none', 'preload is set to none'); - QUnit.equal(player.options_.id, 'example_1', 'id is set to example_1'); - QUnit.equal(player.options_.sources.length, 2, 'we have two sources'); - QUnit.equal(player.options_.sources[0].src, 'http://google.com', 'first source is google.com'); - QUnit.equal(player.options_.sources[0].type, 'video/mp4', 'first time is video/mp4'); - QUnit.equal(player.options_.sources[1].type, 'video/webm', 'second type is video/webm'); - QUnit.equal(player.options_.tracks.length, 1, 'we have one text track'); - QUnit.equal(player.options_.tracks[0].kind, 'captions', 'the text track is a captions file'); - QUnit.equal(player.options_.tracks[0].attrtest, '', 'we have an empty attribute called attrtest'); + assert.equal(player.options_.autoplay, true, 'autoplay is set to true'); + assert.equal(player.options_.preload, 'none', 'preload is set to none'); + assert.equal(player.options_.id, 'example_1', 'id is set to example_1'); + assert.equal(player.options_.sources.length, 2, 'we have two sources'); + assert.equal(player.options_.sources[0].src, 'http://google.com', 'first source is google.com'); + assert.equal(player.options_.sources[0].type, 'video/mp4', 'first time is video/mp4'); + assert.equal(player.options_.sources[1].type, 'video/webm', 'second type is video/webm'); + assert.equal(player.options_.tracks.length, 1, 'we have one text track'); + assert.equal(player.options_.tracks[0].kind, 'captions', 'the text track is a captions file'); + assert.equal(player.options_.tracks[0].attrtest, '', 'we have an empty attribute called attrtest'); - QUnit.notEqual(player.el().className.indexOf('video-js'), -1, 'transferred class from tag to player div'); - QUnit.equal(player.el().id, 'example_1', 'transferred id from tag to player div'); + assert.notEqual(player.el().className.indexOf('video-js'), -1, 'transferred class from tag to player div'); + assert.equal(player.el().id, 'example_1', 'transferred id from tag to player div'); - QUnit.equal(Player.players[player.id()], player, 'player referenceable from global list'); - QUnit.notEqual(tag.id, player.id, 'tag ID no longer is the same as player ID'); - QUnit.notEqual(tag.className, player.el().className, 'tag classname updated'); + assert.equal(Player.players[player.id()], player, 'player referenceable from global list'); + assert.notEqual(tag.id, player.id, 'tag ID no longer is the same as player ID'); + assert.notEqual(tag.className, player.el().className, 'tag classname updated'); player.dispose(); - QUnit.notEqual(tag.player, player, 'tag player ref killed'); - QUnit.ok(!Player.players.example_1, 'global player ref killed'); - QUnit.equal(player.el(), null, 'player el killed'); + assert.notEqual(tag.player, player, 'tag player ref killed'); + assert.ok(!Player.players.example_1, 'global player ref killed'); + assert.equal(player.el(), null, 'player el killed'); }); -QUnit.test('should asynchronously fire error events during source selection', function() { - QUnit.expect(2); +QUnit.test('should asynchronously fire error events during source selection', function(assert) { + assert.expect(2); sinon.stub(log, 'error'); @@ -132,10 +132,10 @@ QUnit.test('should asynchronously fire error events during source selection', fu ] }); - QUnit.ok(player.options_.techOrder[0] === 'foo', 'Foo listed as the only tech'); + assert.ok(player.options_.techOrder[0] === 'foo', 'Foo listed as the only tech'); player.on('error', function(e) { - QUnit.ok(player.error().code === 4, 'Source could not be played error thrown'); + assert.ok(player.error().code === 4, 'Source could not be played error thrown'); }); this.clock.tick(1); @@ -144,7 +144,7 @@ QUnit.test('should asynchronously fire error events during source selection', fu log.error.restore(); }); -QUnit.test('should set the width, height, and aspect ratio via a css class', function() { +QUnit.test('should set the width, height, and aspect ratio via a css class', function(assert) { const player = TestHelpers.makePlayer(); const getStyleText = function(styleEl) { return (styleEl.styleSheet && styleEl.styleSheet.cssText) || styleEl.innerHTML; @@ -163,34 +163,34 @@ QUnit.test('should set the width, height, and aspect ratio via a css class', fun }; // Initial state - QUnit.ok(!getStyleText(player.styleEl_), 'style element should be empty when the player is given no dimensions'); + assert.ok(!getStyleText(player.styleEl_), 'style element should be empty when the player is given no dimensions'); // Set only the width player.width(100); - QUnit.ok(confirmSetting('width', '100px'), 'style width should equal the supplied width in pixels'); - QUnit.ok(confirmSetting('height', '56.25px'), 'style height should match the default aspect ratio of the width'); + assert.ok(confirmSetting('width', '100px'), 'style width should equal the supplied width in pixels'); + assert.ok(confirmSetting('height', '56.25px'), 'style height should match the default aspect ratio of the width'); // Set the height player.height(200); - QUnit.ok(confirmSetting('height', '200px'), 'style height should match the supplied height in pixels'); + assert.ok(confirmSetting('height', '200px'), 'style height should match the supplied height in pixels'); // Reset the width and height to defaults player.width(''); player.height(''); - QUnit.ok(confirmSetting('width', '300px'), 'supplying an empty string should reset the width'); - QUnit.ok(confirmSetting('height', '168.75px'), 'supplying an empty string should reset the height'); + assert.ok(confirmSetting('width', '300px'), 'supplying an empty string should reset the width'); + assert.ok(confirmSetting('height', '168.75px'), 'supplying an empty string should reset the height'); // Switch to fluid mode player.fluid(true); - QUnit.ok(player.hasClass('vjs-fluid'), 'the vjs-fluid class should be added to the player'); - QUnit.ok(confirmSetting('padding-top', '56.25%'), 'fluid aspect ratio should match the default aspect ratio'); + assert.ok(player.hasClass('vjs-fluid'), 'the vjs-fluid class should be added to the player'); + assert.ok(confirmSetting('padding-top', '56.25%'), 'fluid aspect ratio should match the default aspect ratio'); // Change the aspect ratio player.aspectRatio('4:1'); - QUnit.ok(confirmSetting('padding-top', '25%'), 'aspect ratio percent should match the newly set aspect ratio'); + assert.ok(confirmSetting('padding-top', '25%'), 'aspect ratio percent should match the newly set aspect ratio'); }); -QUnit.test('should use an class name that begins with an alpha character', function() { +QUnit.test('should use an class name that begins with an alpha character', function(assert) { const alphaPlayer = TestHelpers.makePlayer({ id: 'alpha1' }); const numericPlayer = TestHelpers.makePlayer({ id: '1numeric' }); @@ -201,11 +201,11 @@ QUnit.test('should use an class name that begins with an alpha character', funct alphaPlayer.width(100); numericPlayer.width(100); - QUnit.ok(/\s*\.alpha1-dimensions\s*\{/.test(getStyleText(alphaPlayer.styleEl_)), 'appends -dimensions to an alpha player ID'); - QUnit.ok(/\s*\.dimensions-1numeric\s*\{/.test(getStyleText(numericPlayer.styleEl_)), 'prepends dimensions- to a numeric player ID'); + assert.ok(/\s*\.alpha1-dimensions\s*\{/.test(getStyleText(alphaPlayer.styleEl_)), 'appends -dimensions to an alpha player ID'); + assert.ok(/\s*\.dimensions-1numeric\s*\{/.test(getStyleText(numericPlayer.styleEl_)), 'prepends dimensions- to a numeric player ID'); }); -QUnit.test('should wrap the original tag in the player div', function() { +QUnit.test('should wrap the original tag in the player div', function(assert) { const tag = TestHelpers.makeTag(); const container = document.createElement('div'); const fixture = document.getElementById('qunit-fixture'); @@ -216,14 +216,14 @@ QUnit.test('should wrap the original tag in the player div', function() { const player = new Player(tag, { techOrder: ['techFaker'] }); const el = player.el(); - QUnit.ok(el.parentNode === container, 'player placed at same level as tag'); + assert.ok(el.parentNode === container, 'player placed at same level as tag'); // Tag may be placed inside the player element or it may be removed from the DOM - QUnit.ok(tag.parentNode !== container, 'tag removed from original place'); + assert.ok(tag.parentNode !== container, 'tag removed from original place'); player.dispose(); }); -QUnit.test('should set and update the poster value', function() { +QUnit.test('should set and update the poster value', function(assert) { const poster = '#'; const updatedPoster = 'http://example.com/updated-poster.jpg'; @@ -233,7 +233,7 @@ QUnit.test('should set and update the poster value', function() { const player = TestHelpers.makePlayer({}, tag); - QUnit.equal(player.poster(), poster, 'the poster property should equal the tag attribute'); + assert.equal(player.poster(), poster, 'the poster property should equal the tag attribute'); let pcEmitted = false; @@ -242,8 +242,8 @@ QUnit.test('should set and update the poster value', function() { }); player.poster(updatedPoster); - QUnit.ok(pcEmitted, 'posterchange event was emitted'); - QUnit.equal(player.poster(), updatedPoster, 'the updated poster is returned'); + assert.ok(pcEmitted, 'posterchange event was emitted'); + assert.equal(player.poster(), updatedPoster, 'the updated poster is returned'); player.dispose(); }); @@ -251,23 +251,23 @@ QUnit.test('should set and update the poster value', function() { // hasStarted() is equivalent to the "show poster flag" in the // standard, for the purpose of displaying the poster image // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-play -QUnit.test('should hide the poster when play is called', function() { +QUnit.test('should hide the poster when play is called', function(assert) { const player = TestHelpers.makePlayer({ poster: 'https://example.com/poster.jpg' }); - QUnit.equal(player.hasStarted(), false, 'the show poster flag is true before play'); + assert.equal(player.hasStarted(), false, 'the show poster flag is true before play'); player.tech_.trigger('play'); - QUnit.equal(player.hasStarted(), true, 'the show poster flag is false after play'); + assert.equal(player.hasStarted(), true, 'the show poster flag is false after play'); player.tech_.trigger('loadstart'); - QUnit.equal(player.hasStarted(), false, 'the resource selection algorithm sets the show poster flag to true'); + assert.equal(player.hasStarted(), false, 'the resource selection algorithm sets the show poster flag to true'); player.tech_.trigger('play'); - QUnit.equal(player.hasStarted(), true, 'the show poster flag is false after play'); + assert.equal(player.hasStarted(), true, 'the show poster flag is false after play'); }); -QUnit.test('should load a media controller', function() { +QUnit.test('should load a media controller', function(assert) { const player = TestHelpers.makePlayer({ preload: 'none', sources: [ @@ -276,12 +276,12 @@ QUnit.test('should load a media controller', function() { ] }); - QUnit.ok(player.el().children[0].className.indexOf('vjs-tech') !== -1, 'media controller loaded'); + assert.ok(player.el().children[0].className.indexOf('vjs-tech') !== -1, 'media controller loaded'); player.dispose(); }); -QUnit.test('should be able to initialize player twice on the same tag using string reference', function() { +QUnit.test('should be able to initialize player twice on the same tag using string reference', function(assert) { let videoTag = TestHelpers.makeTag(); const id = videoTag.id; @@ -291,10 +291,10 @@ QUnit.test('should be able to initialize player twice on the same tag using stri let player = videojs(videoTag.id, { techOrder: ['techFaker'] }); - QUnit.ok(player, 'player is created'); + assert.ok(player, 'player is created'); player.dispose(); - QUnit.ok(!document.getElementById(id), 'element is removed'); + assert.ok(!document.getElementById(id), 'element is removed'); videoTag = TestHelpers.makeTag(); fixture.appendChild(videoTag); @@ -304,61 +304,61 @@ QUnit.test('should be able to initialize player twice on the same tag using stri player.dispose(); }); -QUnit.test('should set controls and trigger events', function() { +QUnit.test('should set controls and trigger events', function(assert) { const player = TestHelpers.makePlayer({ controls: false }); - QUnit.ok(player.controls() === false, 'controls set through options'); + assert.ok(player.controls() === false, 'controls set through options'); const hasDisabledClass = player.el().className.indexOf('vjs-controls-disabled'); - QUnit.ok(hasDisabledClass !== -1, 'Disabled class added to player'); + assert.ok(hasDisabledClass !== -1, 'Disabled class added to player'); player.controls(true); - QUnit.ok(player.controls() === true, 'controls updated'); + assert.ok(player.controls() === true, 'controls updated'); const hasEnabledClass = player.el().className.indexOf('vjs-controls-enabled'); - QUnit.ok(hasEnabledClass !== -1, 'Disabled class added to player'); + assert.ok(hasEnabledClass !== -1, 'Disabled class added to player'); player.on('controlsenabled', function() { - QUnit.ok(true, 'enabled fired once'); + assert.ok(true, 'enabled fired once'); }); player.on('controlsdisabled', function() { - QUnit.ok(true, 'disabled fired once'); + assert.ok(true, 'disabled fired once'); }); player.controls(false); player.dispose(); }); -QUnit.test('should toggle user the user state between active and inactive', function() { +QUnit.test('should toggle user the user state between active and inactive', function(assert) { const player = TestHelpers.makePlayer({}); - QUnit.expect(9); + assert.expect(9); - QUnit.ok(player.userActive(), 'User should be active at player init'); + assert.ok(player.userActive(), 'User should be active at player init'); player.on('userinactive', function() { - QUnit.ok(true, 'userinactive event triggered'); + assert.ok(true, 'userinactive event triggered'); }); player.on('useractive', function() { - QUnit.ok(true, 'useractive event triggered'); + assert.ok(true, 'useractive event triggered'); }); player.userActive(false); - QUnit.ok(player.userActive() === false, 'Player state changed to inactive'); - QUnit.ok(player.el().className.indexOf('vjs-user-active') === -1, 'Active class removed'); - QUnit.ok(player.el().className.indexOf('vjs-user-inactive') !== -1, 'Inactive class added'); + assert.ok(player.userActive() === false, 'Player state changed to inactive'); + assert.ok(player.el().className.indexOf('vjs-user-active') === -1, 'Active class removed'); + assert.ok(player.el().className.indexOf('vjs-user-inactive') !== -1, 'Inactive class added'); player.userActive(true); - QUnit.ok(player.userActive() === true, 'Player state changed to active'); - QUnit.ok(player.el().className.indexOf('vjs-user-inactive') === -1, 'Inactive class removed'); - QUnit.ok(player.el().className.indexOf('vjs-user-active') !== -1, 'Active class added'); + assert.ok(player.userActive() === true, 'Player state changed to active'); + assert.ok(player.el().className.indexOf('vjs-user-inactive') === -1, 'Inactive class removed'); + assert.ok(player.el().className.indexOf('vjs-user-active') !== -1, 'Active class added'); player.dispose(); }); -QUnit.test('should add a touch-enabled classname when touch is supported', function() { - QUnit.expect(1); +QUnit.test('should add a touch-enabled classname when touch is supported', function(assert) { + assert.expect(1); // Fake touch support. Real touch support isn't needed for this test. const origTouch = browser.TOUCH_ENABLED; @@ -367,40 +367,40 @@ QUnit.test('should add a touch-enabled classname when touch is supported', funct const player = TestHelpers.makePlayer({}); - QUnit.ok(player.el().className.indexOf('vjs-touch-enabled'), 'touch-enabled classname added'); + assert.ok(player.el().className.indexOf('vjs-touch-enabled'), 'touch-enabled classname added'); browser.TOUCH_ENABLED = origTouch; player.dispose(); }); -QUnit.test('should allow for tracking when native controls are used', function() { +QUnit.test('should allow for tracking when native controls are used', function(assert) { const player = TestHelpers.makePlayer({}); - QUnit.expect(6); + assert.expect(6); // Make sure native controls is false before starting test player.usingNativeControls(false); player.on('usingnativecontrols', function() { - QUnit.ok(true, 'usingnativecontrols event triggered'); + assert.ok(true, 'usingnativecontrols event triggered'); }); player.on('usingcustomcontrols', function() { - QUnit.ok(true, 'usingcustomcontrols event triggered'); + assert.ok(true, 'usingcustomcontrols event triggered'); }); player.usingNativeControls(true); - QUnit.ok(player.usingNativeControls() === true, 'Using native controls is true'); - QUnit.ok(player.el().className.indexOf('vjs-using-native-controls') !== -1, 'Native controls class added'); + assert.ok(player.usingNativeControls() === true, 'Using native controls is true'); + assert.ok(player.el().className.indexOf('vjs-using-native-controls') !== -1, 'Native controls class added'); player.usingNativeControls(false); - QUnit.ok(player.usingNativeControls() === false, 'Using native controls is false'); - QUnit.ok(player.el().className.indexOf('vjs-using-native-controls') === -1, 'Native controls class removed'); + assert.ok(player.usingNativeControls() === false, 'Using native controls is false'); + assert.ok(player.el().className.indexOf('vjs-using-native-controls') === -1, 'Native controls class removed'); player.dispose(); }); -QUnit.test('make sure that controls listeners do not get added too many times', function() { +QUnit.test('make sure that controls listeners do not get added too many times', function(assert) { const player = TestHelpers.makePlayer({}); let listeners = 0; @@ -415,18 +415,18 @@ QUnit.test('make sure that controls listeners do not get added too many times', player.controls(true); - QUnit.equal(listeners, 0, 'addTechControlsListeners_ should not have gotten called yet'); + assert.equal(listeners, 0, 'addTechControlsListeners_ should not have gotten called yet'); player.usingNativeControls(false); player.controls(false); player.controls(true); - QUnit.equal(listeners, 1, 'addTechControlsListeners_ should have gotten called once'); + assert.equal(listeners, 1, 'addTechControlsListeners_ should have gotten called once'); player.dispose(); }); -QUnit.test('should select the proper tech based on the the sourceOrder option', function() { +QUnit.test('should select the proper tech based on the the sourceOrder option', function(assert) { const fixture = document.getElementById('qunit-fixture'); const html = '