log.js 1.0 KB

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