Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/parallel/test-crypto-hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,10 @@ common.expectsError(
message: 'The "algorithm" argument must be of type string'
}
);

{
const Hash = crypto.Hash;
const instance = crypto.Hash('sha256');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createHash

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same adobe #17458 (comment)

assert(instance instanceof Hash, 'Hash is expected to return a new instance' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a space either at the end of this line (after instance) or on the next line. Right now it says "instancewhen".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, Sorry. I'll update it soon.

' when called without `new`');
}
24 changes: 24 additions & 0 deletions test/parallel/test-crypto-hmac.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ if (!common.hasCrypto)
const assert = require('assert');
const crypto = require('crypto');

{
const Hmac = crypto.Hmac;
const instance = crypto.Hmac('sha256', 'Node');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createHmac

assert(instance instanceof Hmac, 'Hmac is expected to return a new instance' +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

' when called without `new`');
}

common.expectsError(
() => new crypto.Hmac(null),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "hmac" argument must be of type string'
});

common.expectsError(
() => new crypto.Hmac('sha1', null),
{
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "key" argument must be one of type string, TypedArray, or ' +
'DataView'
});

{
// Test HMAC
const actual = crypto.createHmac('sha1', 'Node')
Expand Down