diff options
author | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-04-23 14:54:23 +0200 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2018-04-25 06:21:29 +0200 |
commit | 95197ed2b052b1fee312cfc127a9f67844dd77b7 (patch) | |
tree | a4b3ddaa994d16bea93c71cde71e7c63479dfd12 /test/parallel/test-crypto-certificate.js | |
parent | c521a20f43a12368625ce9bb42b67af1572a04b8 (diff) | |
download | android-node-v8-95197ed2b052b1fee312cfc127a9f67844dd77b7.tar.gz android-node-v8-95197ed2b052b1fee312cfc127a9f67844dd77b7.tar.bz2 android-node-v8-95197ed2b052b1fee312cfc127a9f67844dd77b7.zip |
test: add checkMethods function for Certificate
This commit adds a checkMethods function so that it can be reused to
avoid duplicating the same code for instance methods, and static
methods of the Certificate object.
PR-URL: https://github.com/nodejs/node/pull/20224
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-certificate.js')
-rw-r--r-- | test/parallel/test-crypto-certificate.js | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index acbfdf66cc..a426e0be00 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/test/parallel/test-crypto-certificate.js @@ -34,9 +34,7 @@ const spkacValid = fixtures.readSync('spkac.valid'); const spkacFail = fixtures.readSync('spkac.fail'); const spkacPem = fixtures.readSync('spkac.pem'); -{ - // Test instance methods - const certificate = new Certificate(); +function checkMethods(certificate) { assert.strictEqual(certificate.verifySpkac(spkacValid), true); assert.strictEqual(certificate.verifySpkac(spkacFail), false); @@ -55,21 +53,13 @@ const spkacPem = fixtures.readSync('spkac.pem'); } { - // Test static methods - assert.strictEqual(Certificate.verifySpkac(spkacValid), true); - assert.strictEqual(Certificate.verifySpkac(spkacFail), false); - - assert.strictEqual( - stripLineEndings(Certificate.exportPublicKey(spkacValid).toString('utf8')), - stripLineEndings(spkacPem.toString('utf8')) - ); - assert.strictEqual(Certificate.exportPublicKey(spkacFail), ''); + // Test instance methods + checkMethods(new Certificate()); +} - assert.strictEqual( - Certificate.exportChallenge(spkacValid).toString('utf8'), - 'fb9ab814-6677-42a4-a60c-f905d1a6924d' - ); - assert.strictEqual(Certificate.exportChallenge(spkacFail), ''); +{ + // Test static methods + checkMethods(Certificate); } function stripLineEndings(obj) { |