Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
erezrokah committed Jan 28, 2021
1 parent 4aefeb3 commit 4ac0d91
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
97 changes: 97 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"esm": "^3.2.25",
"nyc": "^15.1.0",
"semantic-release": "^17.1.1",
"sinon": "^9.2.4",
"typescript": "^4.0.0",
"uglify-js": "^3.0.0"
},
Expand Down
14 changes: 14 additions & 0 deletions tests/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Buffer } from 'buffer';

import test from 'ava';
import sinon from 'sinon';

import User from '../src/user.js';

Expand All @@ -24,3 +25,16 @@ test('should parse token in ctor', (t) => {

t.is(user.token.expires_at, 1000000);
});

test('should not log token on error', (t) => {
const spy = sinon.spy(console, 'error');
const tokenResponse = {
access_token: 'header.invalid.secret',
};

// eslint-disable-next-line no-new
new User({}, tokenResponse, '');

t.assert(spy.calledOnce);
t.false(spy.getCall(0).args[0].message.includes(tokenResponse.access_token));
});

0 comments on commit 4ac0d91

Please sign in to comment.