Skip to content

Commit 40bf0ee

Browse files
eudaimosMylesBorins
authored andcommitted
test: refactor test-crypto-hmac
* replace assert.equals with assert.strictEquals * use template strings where appropriate PR-URL: #9958 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 2823e11 commit 40bf0ee

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/parallel/test-crypto-hmac.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var h1 = crypto.createHmac('sha1', 'Node')
1313
.update('some data')
1414
.update('to hmac')
1515
.digest('hex');
16-
assert.equal(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
16+
assert.strictEqual(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC');
1717

1818
// Test HMAC (Wikipedia Test Cases)
1919
var wikipedia = [
@@ -67,9 +67,9 @@ for (let i = 0, l = wikipedia.length; i < l; i++) {
6767
const result = crypto.createHmac(hash, wikipedia[i]['key'])
6868
.update(wikipedia[i]['data'])
6969
.digest('hex');
70-
assert.equal(wikipedia[i]['hmac'][hash],
71-
result,
72-
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' wikipedia');
70+
assert.strictEqual(wikipedia[i]['hmac'][hash],
71+
result,
72+
`Test HMAC-${hash}: Test case ${i + 1} wikipedia`);
7373
}
7474
}
7575

@@ -233,10 +233,10 @@ for (let i = 0, l = rfc4231.length; i < l; i++) {
233233
result = result.substr(0, 32); // first 128 bits == 32 hex chars
234234
strRes = strRes.substr(0, 32);
235235
}
236-
assert.equal(rfc4231[i]['hmac'][hash],
237-
result,
238-
'Test HMAC-' + hash + ': Test case ' + (i + 1) + ' rfc 4231');
239-
assert.equal(strRes, result, 'Should get same result from stream');
236+
assert.strictEqual(rfc4231[i]['hmac'][hash],
237+
result,
238+
`Test HMAC-${hash}: Test case ${i + 1} rfc 4231`);
239+
assert.strictEqual(strRes, result, 'Should get same result from stream');
240240
}
241241
}
242242

@@ -356,7 +356,7 @@ if (!common.hasFipsCrypto) {
356356
crypto.createHmac('md5', rfc2202_md5[i]['key'])
357357
.update(rfc2202_md5[i]['data'])
358358
.digest('hex'),
359-
'Test HMAC-MD5 : Test case ' + (i + 1) + ' rfc 2202'
359+
`Test HMAC-MD5 : Test case ${i + 1} rfc 2202`
360360
);
361361
}
362362
}
@@ -366,6 +366,6 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) {
366366
crypto.createHmac('sha1', rfc2202_sha1[i]['key'])
367367
.update(rfc2202_sha1[i]['data'])
368368
.digest('hex'),
369-
'Test HMAC-SHA1 : Test case ' + (i + 1) + ' rfc 2202'
369+
`Test HMAC-SHA1 : Test case ${i + 1} rfc 2202`
370370
);
371371
}

0 commit comments

Comments
 (0)