Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
shtukas committed Dec 9, 2024
1 parent 964eb90 commit 2426863
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions handlers/ticket-tailor-webhook/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,26 @@ beforeEach(() => {

test('calls create guest account for new email addresses', async () => {
jest.useFakeTimers().setSystemTime(new Date(validEpochSeconds * 1000)); //Date works in Epoch milli
fetchMock.route(
fetchMock.get(
`https://idapi.code.dev-theguardian.com/user/type/${emailAddress}`,
new Response(JSON.stringify({ userType: 'new' })),
);

fetchMock.route(
fetchMock.post(
'https://idapi.code.dev-theguardian.com/guest?accountVerificationEmail=true',
{
body: { primaryEmailAddress: emailAddress },
method: 'POST',
status: 200
},
);

await handler(sqsEvent);

expect(
fetchMock.called(
`https://idapi.code.dev-theguardian.com/user/type/${emailAddress}`,
),
fetchMock.calls().some(call => call[0] === `https://idapi.code.dev-theguardian.com/user/type/${emailAddress}`)
).toBe(true);
expect(
fetchMock.called(
'https://idapi.code.dev-theguardian.com/guest?accountVerificationEmail=true',
),
fetchMock.calls().some(call => call[0] === 'https://idapi.code.dev-theguardian.com/guest?accountVerificationEmail=true')
).toBe(true);
});

Expand Down

0 comments on commit 2426863

Please sign in to comment.