From 49a07eedd2b54e79d9558bd4cac5c6773d6ea57f Mon Sep 17 00:00:00 2001 From: rzkytmgr Date: Wed, 9 Mar 2022 00:17:55 +0700 Subject: [PATCH] test: add unit test for v3 and v5 to test undefined/null `namespace` --- test/unit/v35.test.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/unit/v35.test.js b/test/unit/v35.test.js index 65f1e752..b0b26433 100644 --- a/test/unit/v35.test.js +++ b/test/unit/v35.test.js @@ -148,6 +148,24 @@ describe('v35', () => { assert.deepEqual(buf, ['landmaster', 'landmaster', 'landmaster'].concat(testBuf)); }); + test('v3 undefined/null', () => { + assert.throws(() => { + v3(); + }); + + assert.throws(() => { + v3('hello'); + }); + + assert.throws(() => { + v3('hello.example.com', undefined); + }); + + assert.throws(() => { + v3('hello.example.com', null, new Array(16)); + }); + }); + test('v5', () => { // Expect to get the same results as http://tools.adjet.org/uuid-v5 assert.strictEqual(v5('hello.example.com', v5.DNS), 'fdda765f-fc57-5604-a269-52a7df8164ec'); @@ -229,6 +247,24 @@ describe('v35', () => { assert.deepEqual(buf, ['landmaster', 'landmaster', 'landmaster'].concat(testBuf)); }); + test('v5 undefined/null', () => { + assert.throws(() => { + v5(); + }); + + assert.throws(() => { + v5('hello'); + }); + + assert.throws(() => { + v5('hello.example.com', undefined); + }); + + assert.throws(() => { + v5('hello.example.com', null, new Array(16)); + }); + }); + test('v3/v5 constants', () => { assert.strictEqual(v3.DNS, '6ba7b810-9dad-11d1-80b4-00c04fd430c8'); assert.strictEqual(v3.URL, '6ba7b811-9dad-11d1-80b4-00c04fd430c8');