Skip to content

Commit

Permalink
no-use-before-define: resolve for some consts (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Sep 18, 2023
1 parent 2221261 commit 8ee1408
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/integration/worker/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down
4 changes: 2 additions & 2 deletions test/unit/util/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
Expand Down
11 changes: 5 additions & 6 deletions test/util/crypto-odk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 8ee1408

Please sign in to comment.