Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(hooks): remove errors logged in tests #3865

Merged
merged 2 commits into from
Dec 15, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function videojs(id, options, ready) {
const opts = hookFunction(tag, mergeOptions(options));

if (!isObject(opts) || Array.isArray(opts)) {
videojs.log.error('please return an object in beforesetup hooks');
log.error('please return an object in beforesetup hooks');
return;
}

Expand Down
10 changes: 10 additions & 0 deletions test/unit/videojs-hooks.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-env qunit */
import videojs from '../../src/js/video.js';
import document from 'global/document';
import log from '../../src/js/utils/log.js';

QUnit.module('video.js:hooks ', {
beforeEach() {
Expand Down Expand Up @@ -112,6 +113,8 @@ QUnit.test('should trigger beforesetup and setup during videojs setup', function
assert.equal(setupCalled, false, 'setup should be called after beforesetup');
assert.deepEqual(options, vjsOptions, 'options should be the same');
assert.equal(video.id, 'test_vid_id', 'video id should be correct');

return options;
};
const setup = function(player) {
setupCalled = true;
Expand Down Expand Up @@ -140,9 +143,14 @@ QUnit.test('should trigger beforesetup and setup during videojs setup', function
});

QUnit.test('beforesetup returns dont break videojs options', function(assert) {
const oldLogError = log.error;
const vjsOptions = {techOrder: ['techFaker']};
const fixture = document.getElementById('qunit-fixture');

log.error = function(err) {
assert.equal(err, 'please return an object in beforesetup hooks', 'we have the correct error');
};

fixture.innerHTML += '<video id="test_vid_id"><source type="video/mp4"></video>';

const vid = document.getElementById('test_vid_id');
Expand All @@ -161,6 +169,8 @@ QUnit.test('beforesetup returns dont break videojs options', function(assert) {

assert.ok(player.options_, 'beforesetup should not destory options');
assert.equal(player.options_.techOrder, vjsOptions.techOrder, 'options set by user should exist');

log.error = oldLogError;
});

QUnit.test('beforesetup options override videojs options', function(assert) {
Expand Down