Skip to content

Commit

Permalink
feedback:fix:test(ts/hooks/useDetour): return different results from …
Browse files Browse the repository at this point in the history
…the API input
  • Loading branch information
firestack committed Jan 22, 2024
1 parent f8e1c77 commit 6adef00
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions assets/tests/hooks/useDetour.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ describe("useDetour", () => {
test("when `addWaypoint` is called, `detourShape` is updated", async () => {
const start = { lat: 0, lon: 0 }
const end = { lat: 1, lon: 1 }
const apiResult = [
{ lat: -1, lon: -1 },
{ lat: -2, lon: -2 },
]

jest
.mocked(fetchDetourDirections)
.mockImplementation((coordinates) =>
Promise.resolve({ coordinates: coordinates })
)
jest.mocked(fetchDetourDirections).mockImplementation((coordinates) => {
expect(coordinates).toStrictEqual([start, end])
return Promise.resolve({ coordinates: apiResult })
})

const { result } = renderHook(useDetour)

Expand All @@ -83,7 +86,7 @@ describe("useDetour", () => {
])

await waitFor(() =>
expect(result.current.detourShape).toStrictEqual([start, end])
expect(result.current.detourShape).toStrictEqual(apiResult)
)
})

Expand Down

0 comments on commit 6adef00

Please sign in to comment.