38 lines
999 B
TypeScript
38 lines
999 B
TypeScript
import { HttpResponse, graphql } from "msw";
|
|
|
|
export function updateAnilistWatchStatus() {
|
|
return graphql.mutation(
|
|
"UpdateWatchStatus",
|
|
({ variables: { titleId, watchStatus }, request: { headers } }) => {
|
|
console.log(
|
|
`Intercepting UpdateWatchStatus mutation with ID ${titleId}, watch status ${watchStatus} and Authorization header ${headers.get("authorization")}`,
|
|
);
|
|
|
|
if (titleId === -1) {
|
|
return HttpResponse.json({
|
|
errors: [
|
|
{
|
|
message: "validation",
|
|
status: 400,
|
|
locations: [
|
|
{
|
|
line: 2,
|
|
column: 2,
|
|
},
|
|
],
|
|
validation: {
|
|
mediaId: ["The selected media id is invalid."],
|
|
},
|
|
},
|
|
],
|
|
data: {
|
|
SaveMediaListEntry: null,
|
|
},
|
|
});
|
|
}
|
|
|
|
return HttpResponse.json({ data: { id: titleId } });
|
|
},
|
|
);
|
|
}
|