-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* renaming handlers for clarity
- Loading branch information
Showing
35 changed files
with
240 additions
and
152 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,32 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { cpocsList } from "../../data/cpocs"; | ||
|
||
const defaultCpocHandler = http.post(/\/getCpocs$/, async () => | ||
HttpResponse.json({ | ||
took: 3, | ||
timed_out: false, | ||
_shards: { | ||
total: 5, | ||
successful: 5, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 654, | ||
relation: "eq", | ||
const defaultApiCpocHandler = http.post( | ||
"https://test-domain.execute-api.us-east-1.amazonaws.com/mocked-tests/getCpocs", | ||
async () => | ||
HttpResponse.json({ | ||
took: 3, | ||
timed_out: false, | ||
_shards: { | ||
total: 5, | ||
successful: 5, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
max_score: 1, | ||
hits: cpocsList, | ||
}, | ||
}), | ||
hits: { | ||
total: { | ||
value: 654, | ||
relation: "eq", | ||
}, | ||
max_score: 1, | ||
hits: cpocsList, | ||
}, | ||
}), | ||
); | ||
|
||
export const errorCpocHandler = http.post( | ||
/\/getCpocs/, | ||
export const errorApiCpocHandler = http.post( | ||
"https://test-domain.execute-api.us-east-1.amazonaws.com/mocked-tests/getCpocs", | ||
() => new HttpResponse(null, { status: 500 }), | ||
); | ||
|
||
export const cpocHandlers = [defaultCpocHandler]; | ||
export const cpocHandlers = [defaultApiCpocHandler]; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import { cpocHandlers } from "./cpocs"; | ||
import { itemHandlers } from "./items"; | ||
import { packageActionHandlers } from "./packageActions"; | ||
import { searchHandlers } from "./search"; | ||
import { submissionHandlers } from "./submissions"; | ||
import { typeHandlers } from "./types"; | ||
|
||
export const apiHandlers = [ | ||
...cpocHandlers, | ||
...itemHandlers, | ||
...packageActionHandlers, | ||
...searchHandlers, | ||
...submissionHandlers, | ||
...typeHandlers, | ||
]; | ||
|
||
export { errorCpocHandler } from "./cpocs"; | ||
export { errorItemHandler, errorItemExistsHandler } from "./items"; | ||
export { errorPackageActionsHandler } from "./packageActions"; | ||
export { errorAttachmentUrlHandler } from "./submissions"; | ||
export { errorSubTypesHandler, errorTypeHandler } from "./types"; | ||
export { errorApiCpocHandler } from "./cpocs"; | ||
export { errorApiItemHandler, errorApiItemExistsHandler } from "./items"; | ||
export { errorApiPackageActionsHandler } from "./packageActions"; | ||
export { errorApiSearchHandler } from "./search"; | ||
export { errorApiAttachmentUrlHandler } from "./submissions"; | ||
export { errorApiSubTypesHandler, errorApiTypeHandler } from "./types"; | ||
export { mockCurrentAuthenticatedUser, mockUseGetUser, mockUserAttributes } from "./user"; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { http, HttpResponse } from "msw"; | ||
import { cpocsList } from "../../data/cpocs"; | ||
|
||
const defaultApiSearchHandler = http.post( | ||
"https://test-domain.execute-api.us-east-1.amazonaws.com/mocked-tests/search/:index", | ||
({ params }) => { | ||
const { index } = params; | ||
|
||
if (index === "cpocs") { | ||
return HttpResponse.json({ | ||
took: 3, | ||
timed_out: false, | ||
_shards: { | ||
total: 5, | ||
successful: 5, | ||
skipped: 0, | ||
failed: 0, | ||
}, | ||
hits: { | ||
total: { | ||
value: 654, | ||
relation: "eq", | ||
}, | ||
max_score: 1, | ||
hits: cpocsList, | ||
}, | ||
}); | ||
} | ||
|
||
return new HttpResponse(null, { status: 200 }); | ||
}, | ||
); | ||
|
||
export const errorApiSearchHandler = http.post( | ||
"https://test-domain.execute-api.us-east-1.amazonaws.com/mocked-tests/search/:index", | ||
() => new HttpResponse("Internal server error", { status: 500 }), | ||
); | ||
|
||
export const searchHandlers = [defaultApiSearchHandler]; |
Oops, something went wrong.