From 3f724f9349d8fde24353dbf9dd4307a3aba47287 Mon Sep 17 00:00:00 2001 From: Gary Katsevman Date: Thu, 15 Dec 2016 15:48:03 -0500 Subject: [PATCH] test(hooks): remove errors logged in tests (#3865) --- src/js/video.js | 2 +- test/unit/videojs-hooks.test.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/video.js b/src/js/video.js index 0e8d981e7..05ddc40a6 100644 --- a/src/js/video.js +++ b/src/js/video.js @@ -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; } diff --git a/test/unit/videojs-hooks.test.js b/test/unit/videojs-hooks.test.js index 190bfcb83..7e37430a1 100644 --- a/test/unit/videojs-hooks.test.js +++ b/test/unit/videojs-hooks.test.js @@ -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() { @@ -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; @@ -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 += ''; const vid = document.getElementById('test_vid_id'); @@ -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) {