From 8ee14089c228f80bcdd2baa57a2fe1cacfb051f9 Mon Sep 17 00:00:00 2001 From: Alex Anderson <191496+alxndrsn@users.noreply.github.com> Date: Mon, 18 Sep 2023 10:49:42 +0300 Subject: [PATCH] no-use-before-define: resolve for some consts (#938) --- test/integration/worker/worker.js | 4 ++-- test/unit/util/zip.js | 4 ++-- test/util/crypto-odk.js | 11 +++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/integration/worker/worker.js b/test/integration/worker/worker.js index 789324966..63a74401d 100644 --- a/test/integration/worker/worker.js +++ b/test/integration/worker/worker.js @@ -36,18 +36,18 @@ describe('worker', () => { it('should pass the container and event details to the job', testContainerFullTrx(async (container) => { const sentineledContainer = container.with({ testSentinel: 108 }); + const event = { id: -1, action: 'test.event', details: { x: 42 } }; + let checked = false; const jobMap = { 'test.event': [ (c, e) => { c.testSentinel.should.equal(108); c.isTransacting.should.equal(true); c.should.not.equal(container); - // eslint-disable-next-line no-use-before-define e.should.equal(event); checked = true; return Promise.resolve(); } ] }; - const event = { id: -1, action: 'test.event', details: { x: 42 } }; await promisify(runner(sentineledContainer, jobMap))(event); checked.should.equal(true); })); diff --git a/test/unit/util/zip.js b/test/unit/util/zip.js index a7c94e969..f60e60271 100644 --- a/test/unit/util/zip.js +++ b/test/unit/util/zip.js @@ -69,16 +69,16 @@ describe('zipPart streamer', () => { const archive = zipStreamFromParts(part); archive.pipe(createWriteStream('/dev/null')); + const calls = []; + archive.on('end', () => { // despite the fact that 2 gets closed before 1 below, we still expect 1 to // be called back first because it was appended to the archive first, and // the archive works serially. - // eslint-disable-next-line no-use-before-define calls.should.eql([ 1, 2 ]); done(); }); - const calls = []; part.append(file1, { name: 'file' }, () => { calls.push(1); }); file1.push('aoeuaoeu'); part.append(file2, { name: 'file' }, () => { calls.push(2); }); diff --git a/test/util/crypto-odk.js b/test/util/crypto-odk.js index af74d97c2..0dac3dfa7 100644 --- a/test/util/crypto-odk.js +++ b/test/util/crypto-odk.js @@ -8,17 +8,16 @@ const { getSubmissionIvs } = require(appRoot + '/lib/util/crypto'); // here we implement some of the weirdo custom encryption things we need to // properly simulate ODK collect. -// parse our public key and reformulate it into a proper PEM format -// to inflate into a real public key (grumble grumble grumble). -const extractPubkey = (xml) => - // eslint-disable-next-line no-use-before-define - makePubkey(/base64RsaPublicKey="([a-zA-Z0-9+/]{392})"/.exec(xml)[1]); - const makePubkey = (b64) => { const pem = `-----BEGIN PUBLIC KEY-----\n${b64}\n-----END PUBLIC KEY-----`; return createPublicKey(Buffer.from(pem, 'utf8')); }; +// parse our public key and reformulate it into a proper PEM format +// to inflate into a real public key (grumble grumble grumble). +const extractPubkey = (xml) => + makePubkey(/base64RsaPublicKey="([a-zA-Z0-9+/]{392})"/.exec(xml)[1]); + // eslint-disable-next-line arrow-body-style const extractVersion = (xml) => { return /version="([^"]+)"/.exec(xml)[1];