Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Polling tests] Add Handle unexpected errors #162

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/composable/ConditionalOrder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,30 @@ describe('Poll Single Orders', () => {
reason: 'InvalidConditionalOrder. Reason: ' + validationError,
})
})

test('[UNEXPECTED_ERROR] getTradeableOrderWithSignature throws an error', async () => {
// GIVEN: getTradeableOrderWithSignature throws
const error = new Error(`I'm sorry, but is not a good time to trade`)
mockGetTradeableOrderWithSignature.mockImplementation(() => {
throw error
})

// GIVEN: Every validation is OK (auth + contract returns an order + order is valid)
const order = createOrder()
const mockIsValid = jest.fn(order.isValid).mockReturnValue({ isValid: true })
order.isValid = mockIsValid
mockSingleOrders.mockReturnValue(true)

// WHEN: we poll
const pollResult = await order.poll(param)

// THEN: we expect 1 CALL to the
expect(mockGetTradeableOrderWithSignature).toBeCalledTimes(1)

// THEN: We receive an unexpected error
expect(pollResult).toEqual({
result: PollResultCode.UNEXPECTED_ERROR,
error,
})
})
})
Loading