forked from nicolaspanel/numjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.spec.js
37 lines (34 loc) · 1.21 KB
/
errors.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* eslint-env mocha */
'use strict';
var expect = require('expect.js');
var util = require('util');
var errors = require('../../src/errors');
describe('errors', function () {
it('can be a ValueError', function () {
expect(function () {
throw new errors.ValueError('txt...');
}).to.throwException(function (e) { // get the exception object
expect(e.name).to.equal('ValueError');
expect(util.isError(e)).to.equal(true);
expect(e.toString()).to.equal('ValueError: txt...');
});
});
it('can be a ConfigError', function () {
expect(function () {
throw new errors.ConfigError('txt...');
}).to.throwException(function (e) { // get the exception object
expect(e.name).to.equal('ConfigError');
expect(util.isError(e)).to.equal(true);
expect(e.toString()).to.equal('ConfigError: txt...');
});
});
it('can be a NotImplementedError', function () {
expect(function () {
throw new errors.NotImplementedError();
}).to.throwException(function (e) { // get the exception object
expect(e.name).to.equal('NotImplementedError');
expect(util.isError(e)).to.equal(true);
expect(e.toString()).to.equal('NotImplementedError');
});
});
});