Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Sep 10, 2024
1 parent ef50f8b commit 3718487
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions src/swap/components/SwapProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,10 @@ describe('SwapProvider', () => {
const button = screen.getByText('setLifeCycleStatus.transactionPending');
fireEvent.click(button);
await waitFor(() => {
expect(onStatusMock).toHaveBeenCalledWith(
expect.objectContaining({
statusName: 'transactionPending',
statusData: null,
}),
);
expect(onStatusMock).toHaveBeenCalledWith({
statusName: 'transactionPending',
statusData: null,
});
});
});

Expand Down Expand Up @@ -417,26 +415,22 @@ describe('SwapProvider', () => {
const button = screen.getByText('setLifeCycleStatus.success');
fireEvent.click(button);
await waitFor(() => {
expect(onStatusMock).toHaveBeenCalledWith(
expect.objectContaining({
statusName: 'success',
statusData: expect.objectContaining({
receipt: ['0x123'],
}),
}),
);
expect(onStatusMock).toHaveBeenCalledWith({
statusName: 'success',
statusData: {
receipt: ['0x123'],
},
});
});
await waitFor(() => {
expect(onStatusMock).toHaveBeenCalledWith(
expect.objectContaining({
statusName: 'init',
statusData: expect.objectContaining({
isMissingRequiredField: false,
maxSlippage: expect.any(Number),
}),
}),
);
});
expect(onStatusMock).toHaveBeenCalledWith({

Check failure on line 426 in src/swap/components/SwapProvider.test.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

src/swap/components/SwapProvider.test.tsx > SwapProvider > should reset status to init when setLifeCycleStatus is called with success

AssertionError: expected "spy" to be called with arguments: [ { statusName: 'init', …(1) } ] Received: 1st spy call: Array [ Object { "statusData": Object { - "isMissingRequiredField": false, - "maxSlippage": Any<Number>, + "isMissingRequiredField": true, + "maxSlippage": 10, }, "statusName": "init", }, ] 2nd spy call: Array [ Object { "statusData": Object { - "isMissingRequiredField": false, - "maxSlippage": Any<Number>, + "receipt": Array [ + "0x123", + ], }, - "statusName": "init", + "statusName": "success", }, ] 3rd spy call: Array [ Object { "statusData": Object { "isMissingRequiredField": false, - "maxSlippage": Any<Number>, + "maxSlippage": undefined, }, "statusName": "init", }, ] Number of calls: 3 Ignored nodes: comments, script, style <html> <head /> <body> <div> <div data-testid="test-component" > <span data-testid="context-value-lifeCycleStatus-statusName" > init </span> <button type="button" > setLifeCycleStatus.error </button> <button type="button" > setLifeCycleStatus.amountChange </button> <button type="button" > setLifeCycleStatus.transactionPending </button> <button type="button" > setLifeCycleStatus.transactionApproved </button> <button type="button" > setLifeCycleStatus.success </button> <button type="submit" > Swap </button> </div> </div> </body> </html> ❯ __vi_import_2__.waitFor.timeout src/swap/components/SwapProvider.test.tsx:426:28 ❯ runWithExpensiveErrorDiagnosticsDisabled node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/config.js:47:12 ❯ checkCallback node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/wait-for.js:124:77 ❯ Timeout.checkRealTimersCallback node_modules/@testing-library/react/node_modules/@testing-library/dom/dist/wait-for.js:118:16
statusName: 'init',
statusData: {
isMissingRequiredField: false,
maxSlippage: expect.any(Number),
},
});
}, { timeout: 3000 }); // Increase timeout if needed
});

it('should emit onStatus when setLifeCycleStatus is called with error', async () => {
Expand Down

0 comments on commit 3718487

Please sign in to comment.