Created
April 29, 2020 06:58
-
-
Save domitriusclark/39418afdd99345056dde84071404aba8 to your computer and use it in GitHub Desktop.
single test from useSearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('updates data to an array on successful request', async () => { | |
let server = new Server({ | |
routes() { | |
this.post("/example-endpoint", () => ({ | |
resources: [ | |
{ id: 1, public_id: "image1" }, | |
{ id: 2, public_id: "image2" }, | |
{ id: 3, public_id: "image3" } | |
] | |
})); | |
}, | |
}); | |
const { result, waitForNextUpdate } = renderHook(() => useSearch({ endpoint: '/example-endpoint' })); | |
act(() => { | |
result.current[0]({ | |
expression: "resource_type:image" | |
}) | |
}); | |
await waitForNextUpdate(); | |
expect(result.current[1].resources[0].id).toBe(1); | |
expect(result.current[1].resources[1].id).toBe(2); | |
expect(result.current[1].resources[2].id).toBe(3); | |
server.shutdown(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment