PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms 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
 1/*global beforeEach, describe, expect, it, spyOn */
 2'use strict';
 3
 4describe('jsdoc/util/error', function() {
 5    var error = require('jsdoc/util/error');
 6    var handle = error.handle;
 7    var logger = require('jsdoc/util/logger');
 8
 9    it('should exist', function() {
10        expect(error).toBeDefined();
11        expect(typeof error).toBe('object');
12    });
13
14    it('should export a "handle" function', function() {
15        expect(handle).toBeDefined();
16        expect(typeof handle).toBe('function');
17    });
18
19    describe('handle', function() {
20        it('should not throw', function() {
21            expect(handle).not.toThrow();
22        });
23
24        it('should log messages with logger.error()', function() {
25            spyOn(logger, 'error');
26            handle('test');
27
28            expect(logger.error).toHaveBeenCalled();
29        });
30
31        it('should use special formatting for Error instances', function() {
32            spyOn(logger, 'error');
33            handle( new Error('Oh no!') );
34
35            expect(logger.error).toHaveBeenCalledWith('Error: Oh no!');
36        });
37    });
38});