1 | 'use strict';
|
2 |
|
3 | var SilentError = require('./');
|
4 | var expect = require('chai').expect;
|
5 |
|
6 | describe('SilentError', function() {
|
7 | var error;
|
8 |
|
9 | it('should suppress the stack trace by default', function() {
|
10 | error = new SilentError();
|
11 | expect(error.suppressStacktrace, 'suppressesStacktrace should be true');
|
12 | });
|
13 |
|
14 | describe('with EMBER_VERBOSE_ERRORS set', function() {
|
15 | beforeEach(function() {
|
16 | delete process.env.EMBER_VERBOSE_ERRORS;
|
17 | });
|
18 |
|
19 | it('should suppress stack when true', function() {
|
20 | process.env.EMBER_VERBOSE_ERRORS = 'true';
|
21 | error = new SilentError();
|
22 | expect(!error.suppressStacktrace, 'suppressesStacktrace should be false');
|
23 | });
|
24 |
|
25 | it('shouldn\'t suppress stack when false', function() {
|
26 | process.env.EMBER_VERBOSE_ERRORS = 'false';
|
27 | error = new SilentError();
|
28 | expect(error.suppressStacktrace, 'suppressesStacktrace should be true');
|
29 | });
|
30 | });
|
31 |
|
32 | describe('debugOrThrow', function() {
|
33 | it('throws non SilentError', function() {
|
34 | expect(function() {
|
35 | SilentError.debugOrThrow('label', new Error('I AM ERROR'));
|
36 | }).to.throw('I AM ERROR');
|
37 | });
|
38 |
|
39 | it('throws false|null|undefined', function() {
|
40 | expect(function() { SilentError.debugOrThrow('label', false); }).to.throw(false);
|
41 | expect(function() { SilentError.debugOrThrow('label', true); }).to.throw(true);
|
42 | expect(function() { SilentError.debugOrThrow('label', undefined); }).to.throw(undefined);
|
43 | expect(function() { SilentError.debugOrThrow('label', null); }).to.throw(null);
|
44 | });
|
45 |
|
46 | it('doesnt throw with SilentError', function() {
|
47 | expect(function() { SilentError.debugOrThrow('label', new SilentError('ERROR')); }).to.not.throw();
|
48 | });
|
49 | });
|
50 | });
|