log.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals console */
  6. 'use strict';
  7. const modules = bender.amd.require( 'core/log' );
  8. let log;
  9. let spy;
  10. beforeEach( () => {
  11. log = modules[ 'core/log' ];
  12. if ( spy ) {
  13. spy.restore();
  14. }
  15. } );
  16. describe( 'warn()', () => {
  17. it( 'logs the message to the console using console.warn()', () => {
  18. let spy = sinon.stub( console, 'warn' );
  19. let data = { bar: 1 };
  20. log.warn( 'foo', data );
  21. sinon.assert.calledOnce( spy );
  22. sinon.assert.calledWith( spy, 'foo', data );
  23. log.warn( 'bar' );
  24. sinon.assert.calledTwice( spy );
  25. sinon.assert.calledWith( spy, 'bar' );
  26. } );
  27. } );
  28. describe( 'error()', () => {
  29. it( 'logs the message to the console using console.error()', () => {
  30. let spy = sinon.stub( console, 'error' );
  31. let data = { bar: 1 };
  32. log.error( 'foo', data );
  33. sinon.assert.calledOnce( spy );
  34. sinon.assert.calledWith( spy, 'foo', data );
  35. log.error( 'bar' );
  36. sinon.assert.calledTwice( spy );
  37. sinon.assert.calledWith( spy, 'bar' );
  38. } );
  39. } );