From 5f2281b1de0ed18b12e7492e612cdaf07a3d727b Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Tue, 26 Nov 2024 10:02:15 -0800 Subject: [PATCH] fix tests with async loops --- test/lib/mystery-box.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/lib/mystery-box.js b/test/lib/mystery-box.js index 84233b3..6ab11db 100644 --- a/test/lib/mystery-box.js +++ b/test/lib/mystery-box.js @@ -336,7 +336,8 @@ describe('MysteryBox', function () { }); it('encrypts and decrypts all available versions no compression', async function () { - Object.keys(mb.versionParameters).map((v) => Number(v)).forEach(async (version) => { + const availableVersions = Object.keys(mb.versionParameters).map((v) => Number(v)); + for await (const version of availableVersions) { object = { foo: 'bar', baz: 'quux', @@ -345,11 +346,12 @@ describe('MysteryBox', function () { const encryptedResult = await mb.pack(object, version, 0x00); const decryptedResult = await mb.unpack(encryptedResult); assert.deepStrictEqual(decryptedResult, object, `${version} results not symmetric`); - }); + } }); it('encrypts and decrypts all available versions +brotli', async function () { - Object.keys(mb.versionParameters).map((v) => Number(v)).forEach(async (version) => { + const availableVersions = Object.keys(mb.versionParameters).map((v) => Number(v)); + for await (const version of availableVersions) { object = { foo: 'bar', baz: 'quux', @@ -358,11 +360,12 @@ describe('MysteryBox', function () { const encryptedResult = await mb.pack(object, version, mb.Flags.Brotli); const decryptedResult = await mb.unpack(encryptedResult); assert.deepStrictEqual(decryptedResult, object, `${version} results not symmetric`); - }); + }; }); it('encrypts and decrypts all available versions +flate', async function () { - Object.keys(mb.versionParameters).map((v) => Number(v)).forEach(async (version) => { + const availableVersions = Object.keys(mb.versionParameters).map((v) => Number(v)); + for await (const version of availableVersions) { object = { foo: 'bar', baz: 'quux', @@ -371,7 +374,7 @@ describe('MysteryBox', function () { const encryptedResult = await mb.pack(object, version, mb.Flags.Flate); const decryptedResult = await mb.unpack(encryptedResult); assert.deepStrictEqual(decryptedResult, object, `${version} results not symmetric`); - }); + }; }); it('handles large object +brotli', async function () { -- 2.49.0