PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/test/specs/jsdoc/util/error.js

https://github.com/zhangyuanwei/jsdoc
JavaScript | 38 lines | 29 code | 8 blank | 1 comment | 1 complexity | c02b50917df1d5ce45e889cfc9e9e545 MD5 | raw file
Possible License(s): Apache-2.0, JSON, MIT
  1. /*global beforeEach, describe, expect, it, spyOn */
  2. 'use strict';
  3. describe('jsdoc/util/error', function() {
  4. var error = require('jsdoc/util/error');
  5. var handle = error.handle;
  6. var logger = require('jsdoc/util/logger');
  7. it('should exist', function() {
  8. expect(error).toBeDefined();
  9. expect(typeof error).toBe('object');
  10. });
  11. it('should export a "handle" function', function() {
  12. expect(handle).toBeDefined();
  13. expect(typeof handle).toBe('function');
  14. });
  15. describe('handle', function() {
  16. it('should not throw', function() {
  17. expect(handle).not.toThrow();
  18. });
  19. it('should log messages with logger.error()', function() {
  20. spyOn(logger, 'error');
  21. handle('test');
  22. expect(logger.error).toHaveBeenCalled();
  23. });
  24. it('should use special formatting for Error instances', function() {
  25. spyOn(logger, 'error');
  26. handle( new Error('Oh no!') );
  27. expect(logger.error).toHaveBeenCalledWith('Error: Oh no!');
  28. });
  29. });
  30. });