forked from m4heshd/better-sqlite3-multiple-ciphers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01.sqlite-error.js
27 lines (26 loc) · 1.06 KB
/
01.sqlite-error.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
'use strict';
const { expect } = require('chai');
const { SqliteError } = require('../.');
describe('SqliteError', function () {
it('should be a subclass of Error', function () {
expect(SqliteError).to.be.a('function');
expect(SqliteError).to.not.equal(Error);
expect(SqliteError.prototype).to.be.an.instanceof(Error);
expect(SqliteError('foo', 'bar')).to.be.an.instanceof(Error);
expect(new SqliteError('foo', 'bar')).to.be.an.instanceof(Error);
});
it('should have the correct name', function () {
expect(SqliteError.prototype.name).to.equal('SqliteError');
});
it('should accept two arguments for setting the message and error code', function () {
const err = SqliteError('foobar', 'baz');
expect(err.message).to.equal('foobar');
expect(err.code).to.equal('baz');
expect(SqliteError(123, 'baz').message).to.equal('123');
expect(() => SqliteError('foo')).to.throw(TypeError);
expect(() => SqliteError('foo', 123)).to.throw(TypeError);
});
it('should capture stack traces', function () {
expect(SqliteError(null, 'baz').stack).to.be.a('string');
});
});