Skip to content

Commit ab48e15

Browse files
author
daniel.santos
committed
OAuthError unit test
1 parent 186d85f commit ab48e15

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@
6363
"lib": "lib",
6464
"test": "test"
6565
}
66-
}
66+
}
6767

test/unit/errors/oauth-error_test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
/**
4+
* Module dependencies.
5+
*/
6+
7+
const { describe, it } = require('mocha');
8+
const should = require('chai').should();
9+
const OAuthError = require('../../../lib/errors/oauth-error');
10+
11+
/**
12+
* Test `OAuthError`.
13+
*/
14+
15+
describe('OAuthError', function() {
16+
describe('constructor()', function() {
17+
it('should get `captureStackTrace`', function() {
18+
19+
const errorFn = function () { throw new OAuthError('test', {name: 'test_error'}); };
20+
21+
try {
22+
errorFn();
23+
24+
should.fail();
25+
} catch (e) {
26+
27+
e.should.be.an.instanceOf(OAuthError);
28+
e.message.should.equal('test');
29+
e.code.should.equal(500);
30+
e.stack.should.not.be.null;
31+
e.stack.should.not.be.undefined;
32+
e.stack.should.include('oauth-error_test.js');
33+
e.stack.should.include('19'); //error lineNUmber
34+
}
35+
});
36+
});
37+
});

0 commit comments

Comments
 (0)