Skip to content

Commit df99550

Browse files
committed
test: update tap/generate_options.ts
1 parent 201e0b1 commit df99550

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

tap/generate_options.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,21 @@ export default async (
99
const { module, test } = QUnit
1010
module('generate_options.ts')
1111

12-
const isWebCrypto =
13-
typeof CryptoKey !== 'undefined' && (await lib.generateSecret('HS256')) instanceof CryptoKey
14-
15-
if (isWebCrypto) {
16-
for (const extractable of [undefined, true, false]) {
17-
test(`secret CryptoKey extractable: ${extractable ?? 'default (false)'}`, async (t) => {
18-
const expected = extractable ?? false
19-
const secret = (await lib.generateSecret('HS256', { extractable })) as CryptoKey
20-
t.equal(secret.extractable, expected)
21-
})
22-
}
12+
for (const extractable of [undefined, true, false]) {
13+
test(`secret CryptoKey extractable: ${extractable ?? 'default (false)'}`, async (t) => {
14+
const expected = extractable ?? false
15+
const secret = (await lib.generateSecret('HS256', { extractable })) as CryptoKey
16+
t.equal(secret.extractable, expected)
17+
})
18+
}
2319

24-
for (const extractable of [undefined, true, false]) {
25-
test(`CryptoKeyPair extractable: ${extractable ?? 'default (false)'}`, async (t) => {
26-
const expected = extractable ?? false
27-
const kp = (await lib.generateKeyPair('ES256', { extractable })) as CryptoKeyPair
28-
t.equal(kp.privateKey.extractable, expected)
29-
t.equal(kp.publicKey.extractable, true)
30-
})
31-
}
20+
for (const extractable of [undefined, true, false]) {
21+
test(`CryptoKeyPair extractable: ${extractable ?? 'default (false)'}`, async (t) => {
22+
const expected = extractable ?? false
23+
const kp = await lib.generateKeyPair('ES256', { extractable })
24+
t.equal(kp.privateKey.extractable, expected)
25+
t.equal(kp.publicKey.extractable, true)
26+
})
3227
}
3328

3429
for (const modulusLength of [undefined, 2048, 3072]) {
@@ -38,16 +33,7 @@ export default async (
3833
modulusLength,
3934
})) as CryptoKeyPair
4035

41-
if (isWebCrypto) {
42-
t.equal((publicKey.algorithm as RsaHashedKeyAlgorithm).modulusLength, expected)
43-
// @ts-ignore
44-
} else if (publicKey.asymmetricKeyDetails) {
45-
// @ts-ignore
46-
t.equal(publicKey.asymmetricKeyDetails.modulusLength, expected)
47-
} else {
48-
// @ts-ignore
49-
t.true(parseInt(process.versions.node, 10) < 16)
50-
}
36+
t.equal((publicKey.algorithm as RsaHashedKeyAlgorithm).modulusLength, expected)
5137
})
5238
}
5339
}

0 commit comments

Comments
 (0)