log.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @license Copyright (c) 2003-2015, 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( 'log' );
  8. let spy;
  9. beforeEach( () => {
  10. if ( spy ) {
  11. spy.restore();
  12. }
  13. } );
  14. describe( 'warn()', () => {
  15. it( 'logs the message to the console using console.warn()', () => {
  16. let log = modules.log;
  17. let spy = sinon.stub( console, 'warn' );
  18. let data = { bar: 1 };
  19. log.warn( 'foo', data );
  20. sinon.assert.calledOnce( spy );
  21. sinon.assert.calledWith( spy, 'foo', data );
  22. log.warn( 'bar' );
  23. sinon.assert.calledTwice( spy );
  24. sinon.assert.calledWith( spy, 'bar' );
  25. } );
  26. } );
  27. describe( 'error()', () => {
  28. it( 'logs the message to the console using console.error()', () => {
  29. let log = modules.log;
  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. } );