Skip to content

Commit

Permalink
test(hooks): remove errors logged in tests (#3865)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev authored Dec 15, 2016
1 parent 559297a commit 3f724f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 3f724f9

Please sign in to comment.