Skip to content

Commit

Permalink
test: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Jan 23, 2024
1 parent cfeb747 commit d294a44
Showing 1 changed file with 9 additions and 120 deletions.
129 changes: 9 additions & 120 deletions packages/react/src/hooks/useTransactionConfirmations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,9 @@ test('default', async () => {

await waitFor(() => expect(result.current.isSuccess).toBeTruthy())

expect(result.current).toMatchInlineSnapshot(`
{
"data": 3488178n,
"dataUpdatedAt": 1675209600000,
"error": null,
"errorUpdateCount": 0,
"errorUpdatedAt": 0,
"failureCount": 0,
"failureReason": null,
"fetchStatus": "idle",
"isError": false,
"isFetched": true,
"isFetchedAfterMount": true,
"isFetching": false,
"isInitialLoading": false,
"isLoading": false,
"isLoadingError": false,
"isPaused": false,
"isPending": false,
"isPlaceholderData": false,
"isRefetchError": false,
"isRefetching": false,
"isStale": true,
"isSuccess": true,
"queryKey": [
"transactionConfirmations",
{
"chainId": 1,
"hash": "0x60668ed8c2dc110d61d945a936fcd45b8f13654e5c78481c8c825d1148c7ef30",
},
],
"refetch": [Function],
"status": "success",
}
`)
const { data, ...rest } = result.current
expect(data).toBeTypeOf('bigint')
expect(rest).toMatchInlineSnapshot()
})

test('parameters: transactionReceipt', async () => {
Expand All @@ -65,56 +33,9 @@ test('parameters: transactionReceipt', async () => {

await waitFor(() => expect(result.current.isSuccess).toBeTruthy())

expect(result.current).toMatchInlineSnapshot(`
{
"data": 3488178n,
"dataUpdatedAt": 1675209600000,
"error": null,
"errorUpdateCount": 0,
"errorUpdatedAt": 0,
"failureCount": 0,
"failureReason": null,
"fetchStatus": "idle",
"isError": false,
"isFetched": true,
"isFetchedAfterMount": true,
"isFetching": false,
"isInitialLoading": false,
"isLoading": false,
"isLoadingError": false,
"isPaused": false,
"isPending": false,
"isPlaceholderData": false,
"isRefetchError": false,
"isRefetching": false,
"isStale": true,
"isSuccess": true,
"queryKey": [
"transactionConfirmations",
{
"chainId": 1,
"transactionReceipt": {
"blockHash": "0xd725a38b51e5ceec8c5f6c9ccfdb2cc423af993bb650af5eedca5e4be7156ba7",
"blockNumber": 15189204n,
"contractAddress": null,
"cumulativeGasUsed": 12949744n,
"effectiveGasPrice": 9371645552n,
"from": "0xa0cf798816d4b9b9866b5330eea46a18382f251e",
"gasUsed": 21000n,
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "success",
"to": "0xd2135cfb216b74109775236e36d4b433f1df507b",
"transactionHash": "0x60668ed8c2dc110d61d945a936fcd45b8f13654e5c78481c8c825d1148c7ef30",
"transactionIndex": 144,
"type": "eip1559",
},
},
],
"refetch": [Function],
"status": "success",
}
`)
const { data, ...rest } = result.current
expect(data).toBeTypeOf('bigint')
expect(rest).toMatchInlineSnapshot()
})

test('behavior: hash: undefined -> defined', async () => {
Expand Down Expand Up @@ -167,41 +88,9 @@ test('behavior: hash: undefined -> defined', async () => {

await waitFor(() => expect(result.current.isSuccess).toBeTruthy())

expect(result.current).toMatchInlineSnapshot(`
{
"data": 3488178n,
"dataUpdatedAt": 1675209600000,
"error": null,
"errorUpdateCount": 0,
"errorUpdatedAt": 0,
"failureCount": 0,
"failureReason": null,
"fetchStatus": "idle",
"isError": false,
"isFetched": true,
"isFetchedAfterMount": true,
"isFetching": false,
"isInitialLoading": false,
"isLoading": false,
"isLoadingError": false,
"isPaused": false,
"isPending": false,
"isPlaceholderData": false,
"isRefetchError": false,
"isRefetching": false,
"isStale": true,
"isSuccess": true,
"queryKey": [
"transactionConfirmations",
{
"chainId": 1,
"hash": "0x60668ed8c2dc110d61d945a936fcd45b8f13654e5c78481c8c825d1148c7ef30",
},
],
"refetch": [Function],
"status": "success",
}
`)
const { data, ...rest } = result.current
expect(data).toBeTypeOf('bigint')
expect(rest).toMatchInlineSnapshot()
})

test('behavior: disabled when properties missing', async () => {
Expand Down

0 comments on commit d294a44

Please sign in to comment.