Skip to content

Commit

Permalink
test: Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 16, 2023
1 parent 548a7d2 commit e2f5b55
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 35 deletions.
4 changes: 1 addition & 3 deletions api.planx.uk/admin/session/bops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { expectedPayload } from "../../tests/mocks/bopsMocks";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/bops`;

const mockGenerateBOPSPayload = jest.fn().mockResolvedValue({
exportData: expectedPayload,
});
const mockGenerateBOPSPayload = jest.fn().mockResolvedValue(expectedPayload);

jest.mock("@opensystemslab/planx-core", () => {
return {
Expand Down
17 changes: 7 additions & 10 deletions api.planx.uk/admin/session/csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import { authHeader } from "../../tests/mockJWT";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/csv`;

const mockGenerateCSVData = jest.fn().mockResolvedValue({
responses: [
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
],
redactedResponses: [],
});
const mockGenerateCSVData = jest.fn().mockResolvedValue([
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
]);
jest.mock("@opensystemslab/planx-core", () => {
return {
CoreDomainClient: jest.fn().mockImplementation(() => ({
Expand Down
4 changes: 3 additions & 1 deletion api.planx.uk/admin/session/oneAppXML.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const mockGenerateOneAppXML = jest
jest.mock("../../client", () => {
return {
$api: {
generateOneAppXML: () => mockGenerateOneAppXML(),
export: {
oneAppPayload: () => mockGenerateOneAppXML(),
},
},
};
});
Expand Down
17 changes: 7 additions & 10 deletions api.planx.uk/send/email.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import supertest from "supertest";
import { queryMock } from "../tests/graphqlQueryMock";
import app from "../server";

const mockGenerateCSVData = jest.fn().mockResolvedValue({
responses: [
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
],
redactedResponses: [],
});
const mockGenerateCSVData = jest.fn().mockResolvedValue([
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
]);
jest.mock("@opensystemslab/planx-core", () => {
return {
Passport: jest.fn().mockImplementation(() => ({
Expand Down
20 changes: 9 additions & 11 deletions api.planx.uk/send/exportZip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,22 @@ const mockGenerateOneAppXML = jest
jest.mock("../client", () => {
return {
$api: {
generateOneAppXML: () => mockGenerateOneAppXML(),
getDocumentTemplateNamesForSession: jest
.fn()
.mockResolvedValue(["X", "Y"]),
session: {
find: () => mockGetSessionById(),
},
export: {
csvData: jest.fn().mockResolvedValue({
responses: [
{
question: "Test",
responses: [{ value: "Answer" }],
metadata: {},
},
],
redactedResponses: [],
}),
csvData: jest.fn().mockResolvedValue([
{
question: "Test",
responses: [{ value: "Answer" }],
metadata: {},
},
]),
csvDataRedacted: jest.fn().mockResolvedValue([]),
oneAppPayload: () => mockGenerateOneAppXML(),
},
},
};
Expand Down

0 comments on commit e2f5b55

Please sign in to comment.