Skip to content

Commit fde0915

Browse files
committed
tests(unit): improve coverage for crypto util
1 parent 323c91b commit fde0915

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unit/utils/crypto-util_test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const cryptoUtil = require('../../../lib/utils/crypto-util');
2+
require('chai').should();
3+
4+
describe(cryptoUtil.createHash.name, function () {
5+
it('creates a hash by given algorithm', function () {
6+
const data = 'client-credentials-grant';
7+
const hash = cryptoUtil.createHash({ data, encoding: 'hex' });
8+
hash.should.equal('072726830f0aadd2d91f86f53e3a7ef40018c2626438152dd576e272bf2b8e60');
9+
});
10+
it('should throw if data is missing', function () {
11+
try {
12+
cryptoUtil.createHash({});
13+
} catch (e) {
14+
e.should.be.instanceOf(TypeError);
15+
e.message.should.include('he "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.');
16+
}
17+
});
18+
});

0 commit comments

Comments
 (0)