Skip to content

Commit

Permalink
Update the unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Jul 11, 2023
1 parent 1aab860 commit 0c0b211
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontend/test/unit/specs/stores/single-result-store.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,18 @@ describe("Media Item Store", () => {
it.each(supportedMediaTypes)(
"fetchMediaItem on 404 sets fetchingError and throws a new error",
async (type) => {
const expectedError = { response: { status: 404 } }
mocks[type].mockImplementationOnce(() => Promise.reject(expectedError))
const errorResponse = { response: { status: 404 } }

mocks[type].mockImplementationOnce(() => Promise.reject(errorResponse))
const singleResultStore = useSingleResultStore()
const id = "foo"

await expect(singleResultStore.fetch(type, id)).rejects.toEqual(
const expectedError = {
message: `Could not fetch ${type} item with id ${id}`,
statusCode: errorResponse.response.status,
}
expect(await singleResultStore.fetch(type, id)).toEqual(null)
expect(singleResultStore.fetchState.fetchingError).toEqual(
expectedError
)
}
Expand Down

0 comments on commit 0c0b211

Please sign in to comment.