summaryrefslogtreecommitdiff
path: root/test/parallel/test-webcrypto-util.js
blob: 4bb14a7f91494fd1c39972f4de03b70c7797e681 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Flags: --expose-internals
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

const assert = require('assert');

const {
  normalizeAlgorithm,
} = require('internal/crypto/util');

{
  // Check that normalizeAlgorithm does not add an undefined hash property.
  assert.strictEqual('hash' in normalizeAlgorithm({ name: 'ECDH' }), false);
  assert.strictEqual('hash' in normalizeAlgorithm('ECDH'), false);
}

{
  // Check that normalizeAlgorithm does not mutate object inputs.
  const algorithm = { name: 'ECDH', hash: 'SHA-256' };
  assert.strictEqual(normalizeAlgorithm(algorithm) !== algorithm, true);
  assert.deepStrictEqual(algorithm, { name: 'ECDH', hash: 'SHA-256' });
}