From 113b773f0c1fc0697f7a80f7403dc9ccf5c74b60 Mon Sep 17 00:00:00 2001 From: SeSo Date: Tue, 18 Jul 2023 14:59:27 -0700 Subject: [PATCH] chore: move mocked data into corresponding tests --- ...ProjectMilestoneReportFormSummary.test.tsx | 198 +++++++++--------- 1 file changed, 99 insertions(+), 99 deletions(-) diff --git a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx index 8f5c29bdc9..93e1921ced 100644 --- a/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx +++ b/app/tests/unit/components/Form/ProjectMilestoneReportFormSummary.test.tsx @@ -120,7 +120,7 @@ describe("The Project Milestone Report Form Summary", () => { componentTestingHelper.reinit(); }); - it("Only displays the data fields that have changed", () => { + it("Displays the data fields that have changed", () => { componentTestingHelper.loadQuery(); componentTestingHelper.renderComponent(); @@ -220,56 +220,56 @@ describe("The Project Milestone Report Form Summary", () => { expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); }); - const latestCommittedData = { - latestCommittedMilestoneFormChanges: { - edges: [ - { - node: { - newFormData: { - totalEligibleExpenses: 1000, - description: "charmander", - projectId: 1, - reportingRequirementIndex: 1, - reportType: "General", - reportDueDate: "2020-01-10T23:59:59.999-07:00", - reportingRequirementId: 1, - hasExpenses: true, - calculatedGrossAmount: 567, - calculatedNetAmount: 789, - calculatedHoldbackAmount: 891, - adjustedNetAmount: 89, - adjustedGrossAmount: 67, - adjustedHoldbackAmount: 91, + it("Displays diffs of the data fields that were updated and shows latest committed values", () => { + const latestCommittedData = { + latestCommittedMilestoneFormChanges: { + edges: [ + { + node: { + newFormData: { + totalEligibleExpenses: 1000, + description: "charmander", + projectId: 1, + reportingRequirementIndex: 1, + reportType: "General", + reportDueDate: "2020-01-10T23:59:59.999-07:00", + reportingRequirementId: 1, + hasExpenses: true, + calculatedGrossAmount: 567, + calculatedNetAmount: 789, + calculatedHoldbackAmount: 891, + adjustedNetAmount: 89, + adjustedGrossAmount: 67, + adjustedHoldbackAmount: 91, + }, }, }, - }, - ], - }, - }; - - const mockQueryPayloadLatestCommitted = { - ...mockQueryPayload, - ProjectRevision() { - const originalProjectRevision = mockQueryPayload.ProjectRevision(); - const modifiedProjectRevision = { - ...originalProjectRevision, - latestCommittedMilestoneFormChanges: { - edges: [ - { - node: { - newFormData: - latestCommittedData.latestCommittedMilestoneFormChanges - .edges[0].node.newFormData, + ], + }, + }; + + const mockQueryPayloadLatestCommitted = { + ...mockQueryPayload, + ProjectRevision() { + const originalProjectRevision = mockQueryPayload.ProjectRevision(); + const modifiedProjectRevision = { + ...originalProjectRevision, + latestCommittedMilestoneFormChanges: { + edges: [ + { + node: { + newFormData: + latestCommittedData.latestCommittedMilestoneFormChanges + .edges[0].node.newFormData, + }, }, - }, - ], - }, - }; - return modifiedProjectRevision; - }, - }; + ], + }, + }; + return modifiedProjectRevision; + }, + }; - it("Displays diffs of the data fields that were updated and shows latest committed values", () => { componentTestingHelper.defaultQueryResolver = mockQueryPayloadLatestCommitted; componentTestingHelper.loadQuery(mockQueryPayloadLatestCommitted); @@ -310,66 +310,66 @@ describe("The Project Milestone Report Form Summary", () => { expect(screen.getByText(/\$88\.00/i)).toBeInTheDocument(); expect(screen.getByText(/\$91\.00/i)).toBeInTheDocument(); }); - const mockQueryPayloadWithDiffs = { - Form() { - return { - jsonSchema: milestoneProdSchema, - }; - }, - ProjectRevision() { - const result = { - isFirstRevision: false, - summaryMilestoneFormChanges: { - edges: [ - { - node: { - id: "Test Reporting Requirement ID - 1", - isPristine: false, - newFormData: { - totalEligibleExpenses: 1000, - description: "charmander", - projectId: 1, - reportingRequirementIndex: 1, - reportType: "General", - reportDueDate: "2020-01-10T23:59:59.999-07:00", - reportingRequirementId: 1, - hasExpenses: true, - calculatedNetAmount: 221, - calculatedGrossAmount: 222, - calculatedHoldbackAmount: 223, - adjustedNetAmount: 21, - adjustedGrossAmount: 22, - adjustedHoldbackAmount: 23, - }, - operation: "UPDATE", - formChangeByPreviousFormChangeId: { + + it("Displays diffs of the data fields that were updated and the old values", () => { + const mockQueryPayloadWithDiffs = { + Form() { + return { + jsonSchema: milestoneProdSchema, + }; + }, + ProjectRevision() { + const result = { + isFirstRevision: false, + summaryMilestoneFormChanges: { + edges: [ + { + node: { + id: "Test Reporting Requirement ID - 1", + isPristine: false, newFormData: { - description: "bulbasaur", + totalEligibleExpenses: 1000, + description: "charmander", projectId: 1, reportingRequirementIndex: 1, - reportDueDate: "2020-01-01T13:59:59.999-07:00", - reportType: "Advanced", + reportType: "General", + reportDueDate: "2020-01-10T23:59:59.999-07:00", reportingRequirementId: 1, hasExpenses: true, - calculatedNetAmount: 111, - calculatedGrossAmount: 112, - calculatedHoldbackAmount: 113, - adjustedNetAmount: 11, - adjustedGrossAmount: 12, - adjustedHoldbackAmount: 13, + calculatedNetAmount: 221, + calculatedGrossAmount: 222, + calculatedHoldbackAmount: 223, + adjustedNetAmount: 21, + adjustedGrossAmount: 22, + adjustedHoldbackAmount: 23, + }, + operation: "UPDATE", + formChangeByPreviousFormChangeId: { + newFormData: { + description: "bulbasaur", + projectId: 1, + reportingRequirementIndex: 1, + reportDueDate: "2020-01-01T13:59:59.999-07:00", + reportType: "Advanced", + reportingRequirementId: 1, + hasExpenses: true, + calculatedNetAmount: 111, + calculatedGrossAmount: 112, + calculatedHoldbackAmount: 113, + adjustedNetAmount: 11, + adjustedGrossAmount: 12, + adjustedHoldbackAmount: 13, + }, }, + formDataRecordId: 1, }, - formDataRecordId: 1, }, - }, - ], - }, - }; - return result; - }, - }; - - it("Displays diffs of the data fields that were updated and the old values", () => { + ], + }, + }; + return result; + }, + }; componentTestingHelper.defaultQueryResolver = mockQueryPayloadWithDiffs; componentTestingHelper.loadQuery(mockQueryPayloadWithDiffs); componentTestingHelper.renderComponent();