1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-12 11:15:04 +02:00
video.js/test/unit/utils/log.test.js

57 lines
1.7 KiB
JavaScript
Raw Normal View History

Broke up Lib and Util into smaller libraries of functions Broke out bind, guid, and element data functions from Lib Separated out more dom functions in to dom.js Broke out URL functions into url.js Removed setLocalStorage since it wasn't being used Moved browser tests out of lib Moved log functions into their own file Removed trim() since it wasn't being used Moved formatTime into its own file Moved round into its own file and renamed roundFloat() Moved capitalize into its own file and renamed as toTitleCase() Moved createTimeRange into its own file Removed Lib.arr.forEach infavor of the native forEach Removed Lib.obj.create in favor of native Object.create (ES6-sham) Removed obj.each in favor of native Object.getOwnPropertyNames().forEach() Removed obj.merge and copy. Using lodash.assign instead. Replaced Lib.obj.isPlain with lodash.isPlainObject Removed Lib.obj.isArray in favor of the native Array.isArray Also removed the lib.js tests file as all tests have been moved or removed. Removed Lib.isEmpty in favor of !Object.getOwnPropertyNames().length Switched Util.mergeOptions and deepMerge to use new mergeOptions() Moved Lib.TEST_VID to Html5.TEST_VID Removed Lib references everywhere. Woo! Attempting to fix sourcemap test errors by setting grunt-browserify version Switched to object.assign from lodash.assign Removed unused 'inherits' dependency Reorganzied test files and added '.test' to file names Combined js/core.js and js/video.js Moved events.js into the utils directory
2015-05-04 01:12:38 +02:00
import log from '../../../src/js/utils/log.js';
import window from 'global/window';
q.module('log');
Broke up Lib and Util into smaller libraries of functions Broke out bind, guid, and element data functions from Lib Separated out more dom functions in to dom.js Broke out URL functions into url.js Removed setLocalStorage since it wasn't being used Moved browser tests out of lib Moved log functions into their own file Removed trim() since it wasn't being used Moved formatTime into its own file Moved round into its own file and renamed roundFloat() Moved capitalize into its own file and renamed as toTitleCase() Moved createTimeRange into its own file Removed Lib.arr.forEach infavor of the native forEach Removed Lib.obj.create in favor of native Object.create (ES6-sham) Removed obj.each in favor of native Object.getOwnPropertyNames().forEach() Removed obj.merge and copy. Using lodash.assign instead. Replaced Lib.obj.isPlain with lodash.isPlainObject Removed Lib.obj.isArray in favor of the native Array.isArray Also removed the lib.js tests file as all tests have been moved or removed. Removed Lib.isEmpty in favor of !Object.getOwnPropertyNames().length Switched Util.mergeOptions and deepMerge to use new mergeOptions() Moved Lib.TEST_VID to Html5.TEST_VID Removed Lib references everywhere. Woo! Attempting to fix sourcemap test errors by setting grunt-browserify version Switched to object.assign from lodash.assign Removed unused 'inherits' dependency Reorganzied test files and added '.test' to file names Combined js/core.js and js/video.js Moved events.js into the utils directory
2015-05-04 01:12:38 +02:00
test('should confirm logging functions work', function() {
let origConsole = window['console'];
// replace the native console for testing
// in ie8 console.log is apparently not a 'function' so sinon chokes on it
// https://github.com/cjohansen/Sinon.JS/issues/386
// instead we'll temporarily replace them with no-op functions
let console = window['console'] = {
log: function(){},
warn: function(){},
error: function(){}
};
// stub the global log functions
let logStub = sinon.stub(console, 'log');
let errorStub = sinon.stub(console, 'error');
let warnStub = sinon.stub(console, 'warn');
// Reset the log history
log.history = [];
log('log1', 'log2');
log.warn('warn1', 'warn2');
log.error('error1', 'error2');
ok(logStub.called, 'log was called');
equal(logStub.firstCall.args[0], 'VIDEOJS:');
equal(logStub.firstCall.args[1], 'log1');
equal(logStub.firstCall.args[2], 'log2');
ok(warnStub.called, 'warn was called');
equal(warnStub.firstCall.args[0], 'VIDEOJS:');
equal(warnStub.firstCall.args[1], 'WARN:');
equal(warnStub.firstCall.args[2], 'warn1');
equal(warnStub.firstCall.args[3], 'warn2');
ok(errorStub.called, 'error was called');
equal(errorStub.firstCall.args[0], 'VIDEOJS:');
equal(errorStub.firstCall.args[1], 'ERROR:');
equal(errorStub.firstCall.args[2], 'error1');
equal(errorStub.firstCall.args[3], 'error2');
equal(log.history.length, 3, 'there should be three messages in the log history');
// tear down sinon
logStub.restore();
errorStub.restore();
warnStub.restore();
// restore the native console
window['console'] = origConsole;
});