8
0

log.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. describe( '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 spy = sinon.stub( console, 'warn' );
  17. let data = { bar: 1 };
  18. log.warn( 'foo', data );
  19. sinon.assert.calledOnce( spy );
  20. sinon.assert.calledWith( spy, 'foo', data );
  21. log.warn( 'bar' );
  22. sinon.assert.calledTwice( spy );
  23. sinon.assert.calledWith( spy, 'bar' );
  24. } );
  25. } );
  26. describe( 'error()', () => {
  27. it( 'logs the message to the console using console.error()', () => {
  28. let spy = sinon.stub( console, 'error' );
  29. let data = { bar: 1 };
  30. log.error( 'foo', data );
  31. sinon.assert.calledOnce( spy );
  32. sinon.assert.calledWith( spy, 'foo', data );
  33. log.error( 'bar' );
  34. sinon.assert.calledTwice( spy );
  35. sinon.assert.calledWith( spy, 'bar' );
  36. } );
  37. } );
  38. } );