Skip to content

Commit

Permalink
test/preprocessors: return promises (#1286)
Browse files Browse the repository at this point in the history
These tests were always passing because their assertions were contained in unreturned promises.
  • Loading branch information
alxndrsn authored Nov 13, 2024
1 parent 695fa2c commit ca1652e
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions test/unit/http/preprocessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ describe('preprocessors', () => {
should.not.exist(context);
}));

it('should prioritise primary auth over Cookie auth', () => {
let caught = false;
it('should prioritise primary auth over Cookie auth', () =>
Promise.resolve(authHandler(
{ Auth, Sessions: mockSessions('alohomora') },
new Context(
Expand All @@ -196,16 +195,9 @@ describe('preprocessors', () => {
}, cookies: { session: 'alohomora' } }),
{ auth: { isAuthenticated() { return false; } }, fieldKey: Option.none() }
)
)).catch((err) => {
err.problemCode.should.equal(401.2);
caught = true;
}).then(() => {
caught.should.equal(true);
});
});
)).should.be.rejectedWith(Problem, { problemCode: 401.2 }));

it('should prioritise fk auth over Cookie auth', () => {
let caught = false;
it('should prioritise fk auth over Cookie auth', () =>
Promise.resolve(authHandler(
{ Auth, Sessions: mockSessions('alohomora') },
new Context(
Expand All @@ -222,13 +214,7 @@ describe('preprocessors', () => {
}),
{ auth: { isAuthenticated() { return false; } }, fieldKey: Option.none() }
)
)).catch((err) => {
err.problemCode.should.equal(401.2);
caught = true;
}).then(() => {
caught.should.equal(true);
});
});
)).should.be.rejectedWith(Problem, { problemCode: 401.2 }));

it('should work for HTTPS GET requests', () =>
Promise.resolve(authHandler(
Expand Down

0 comments on commit ca1652e

Please sign in to comment.