Skip to content

Commit

Permalink
chore: move mocked data into corresponding tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sepehr-Sobhani committed Jul 21, 2023
1 parent 39d7c76 commit 113b773
Showing 1 changed file with 99 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 113b773

Please sign in to comment.