Skip to content

Commit

Permalink
improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeiroguilherme committed Jan 6, 2025
1 parent 3d1f419 commit 8dd954a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/lib/src/components/Klarna/KlarnaPayments.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ describe('KlarnaPayments', () => {
});
}
});
const spy = jest.spyOn(klarna, 'handleAction');
const spy = jest.spyOn(klarna, 'updateWithAction');

render(klarna.render());
klarna.submit();

await waitFor(() => expect(spy).toHaveBeenCalledWith(widgetAction), { interval: 100 });
});

test('should NOT use updateWithAction when action type is NOT "sdk"', async () => {
test('should NOT use updateWithAction when action type is NOT "sdk"', done => {
const action: PaymentAction = {
paymentMethodType: 'klarna_paynow',
type: 'redirect',
Expand All @@ -108,12 +108,15 @@ describe('KlarnaPayments', () => {
});
}
});
const spy = jest.spyOn(klarna, 'handleAction');
const spy = jest.spyOn(klarna, 'updateWithAction');

render(klarna.render());
klarna.submit();

await waitFor(() => expect(spy).not.toHaveBeenCalled(), { interval: 100 });
setTimeout(() => {
expect(spy).not.toHaveBeenCalled();
done();
}, 500);
});
});
});

0 comments on commit 8dd954a

Please sign in to comment.