84 lines
1.5 KiB
TypeScript
84 lines
1.5 KiB
TypeScript
import {MockedResponse} from "@apollo/client/testing";
|
|
import {
|
|
BasicQuestionResponse,
|
|
GET_ALL_QUESTIONS,
|
|
GET_QUESTION_BY_ID,
|
|
GetAllQuestionsResponse,
|
|
GetQuestionByIdResponse
|
|
} from "./question";
|
|
|
|
|
|
export const questionNodesMock: Array<BasicQuestionResponse> = [{
|
|
id: "q1",
|
|
title: "Question 1?",
|
|
description: "Further information for Q1",
|
|
categoryByCategoryRowId: {
|
|
id: "c1",
|
|
rowId: 1,
|
|
title: "Category 1",
|
|
__typename: "Category"
|
|
},
|
|
__typename: "Question",
|
|
},
|
|
{
|
|
id: "q2",
|
|
title: "Question 2?",
|
|
description: "Further information for Q2",
|
|
categoryByCategoryRowId: null,
|
|
__typename: "Question",
|
|
},
|
|
{
|
|
id: "q3",
|
|
title: "Question 3?",
|
|
description: null,
|
|
categoryByCategoryRowId: null,
|
|
__typename: "Question",
|
|
}
|
|
];
|
|
|
|
export const getAllQuestionsMock: Array<MockedResponse<GetAllQuestionsResponse>> = [
|
|
{
|
|
request: {
|
|
query: GET_ALL_QUESTIONS,
|
|
},
|
|
result: {
|
|
data: {
|
|
allQuestions: {
|
|
nodes: questionNodesMock,
|
|
__typename: "QuestionsConnection",
|
|
}
|
|
}
|
|
},
|
|
},
|
|
]
|
|
|
|
export const getQuestionByIdMock: Array<MockedResponse<GetQuestionByIdResponse>> = [
|
|
...questionNodesMock.map(q => ({
|
|
request: {
|
|
query: GET_QUESTION_BY_ID,
|
|
variables: {
|
|
id: q.id,
|
|
},
|
|
},
|
|
result: {
|
|
data: {
|
|
question: q,
|
|
},
|
|
},
|
|
})),
|
|
{
|
|
request: {
|
|
query: GET_QUESTION_BY_ID,
|
|
variables: {
|
|
id: "",
|
|
},
|
|
},
|
|
result: {
|
|
data: {
|
|
question: null,
|
|
},
|
|
},
|
|
}
|
|
]
|
|
|