From 8a2abcfeea4bf2b8e52a27493e6c275711254ada Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Fri, 4 Sep 2026 22:34:00 -0700 Subject: [PATCH] Add test for base64 padding --- test/crypto.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/crypto.test.js b/test/crypto.test.js index 8479abd..a87b37f 100644 --- a/test/crypto.test.js +++ b/test/crypto.test.js @@ -1,5 +1,5 @@ import { suite, test } from 'node:test'; -import { deepStrictEqual, rejects } from 'node:assert/strict'; +import { deepStrictEqual, notDeepStrictEqual, rejects } from 'node:assert/strict'; import { encryptRaw, decryptRaw } from '#src/crypto.js'; @@ -27,6 +27,12 @@ suite('encryptRaw', { concurrency: true }, () => { // @ts-expect-error await rejects(encryptRaw({ version, prf, value: {} }), { name: 'TypeError', message: 'Value "{}" is not a string.' }); }); + test('output value does not have base64 padding', { concurrency: true }, async () => { + for (const value of ['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa', 'aaaaaa', 'aaaaaaa']) { + const output = await encryptRaw({ version, prf, value }); + notDeepStrictEqual(output.at(-1), '='); + } + }); }); suite('decryptRaw', { concurrency: true }, () => { -- 2.47.3