From: Justin Wind Date: Tue, 26 Nov 2024 18:02:15 +0000 (-0800) Subject: fix tests with async loops X-Git-Tag: v2.1.0~4 X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=5f2281b1de0ed18b12e7492e612cdaf07a3d727b;p=squeep-mystery-box fix tests with async loops --- 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 () {