Skip to content

Commit

Permalink
test: update jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BCerki committed Sep 8, 2023
1 parent 04f33ef commit 0fa833e
Showing 1 changed file with 77 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,47 +564,42 @@ describe("The Project Funding Agreement Form Summary", () => {
).toBeInTheDocument();
});

it("Displays relevant message when funding agreement not added", () => {
it("Displays relevant message on summary page when funding agreement not added", () => {
componentTestingHelper.loadQuery({
...mockQueryPayloadEP,
ProjectRevision() {
const result: Partial<ProjectFundingAgreementFormSummary_projectRevision$data> =
{
isFirstRevision: true,
isFirstRevision: false,
projectFormChange: {
asProject: {
fundingStreamRfpByFundingStreamRfpId: {
fundingStreamByFundingStreamId: {
name: "EP",
},
},
},
},
summaryProjectFundingAgreementFormChanges: {
edges: [],
},
};
return result;
},
});
componentTestingHelper.renderComponent();

expect(
screen.getByText(/budgets, expenses & payments not added/i)
).toBeInTheDocument();
});
it("Displays relevant message when funding agreement not updated", () => {
componentTestingHelper.loadQuery({
...mockQueryPayloadEP,
ProjectRevision() {
const result: Partial<ProjectFundingAgreementFormSummary_projectRevision$data> =
{
isFirstRevision: false,
summaryProjectFundingAgreementFormChanges: {
latestCommittedFundingFormChanges: {
edges: [],
},
};
return result;
},
});
componentTestingHelper.renderComponent();
componentTestingHelper.renderComponent(undefined, {
viewOnly: true,
});

expect(
screen.getByText(/budgets, expenses & payments not updated/i)
screen.getByText(/budgets, expenses & payments not added/i)
).toBeInTheDocument();
});
it("Displays relevant message when funding agreement removed", () => {

it("Displays correct diffs when funding agreement removed", () => {
componentTestingHelper.loadQuery({
...mockQueryPayloadEP,
ProjectRevision() {
Expand All @@ -614,31 +609,61 @@ describe("The Project Funding Agreement Form Summary", () => {
summaryProjectFundingAgreementFormChanges: {
edges: [
{
node: {
newFormData: {
projectId: 2,
proponentCost: 245,
maxFundingAmount: 23,
contractStartDate: "2023-08-30T23:59:59.999-07:00",
holdbackPercentage: 10,
provinceSharePercentage: 50,
anticipatedFundingAmount: 246,
projectAssetsLifeEndDate: "2023-09-14T23:59:59.999-07:00",
},
eligibleExpensesToDate: "1.00",
holdbackAmountToDate: "0.10",
netPaymentsToDate: "1.00",
grossPaymentsToDate: "1.00",
calculatedTotalPaymentAmountToDate: "18.4",
proponentsSharePercentage: "91.41791044776119403000",
totalProjectValue: "268",
anticipatedFundingAmountPerFiscalYear: {
edges: [
{
node: {
anticipatedFundingAmount: "1",
fiscalYear: "2023/2024",
},
},
],
},
operation: "ARCHIVE",
formChangeByPreviousFormChangeId: {
newFormData: {
projectId: "Test Project ID",
maxFundingAmount: 200,
provinceSharePercentage: 60,
holdbackPercentage: 20.15,
anticipatedFundingAmount: 300,
proponentCost: 100,
contractStartDate: "2021-02-02T23:59:59.999-07:00",
projectAssetsLifeEndDate: "2021-12-31T23:59:59.999-07:00",
projectId: 2,
proponentCost: 245,
maxFundingAmount: 23,
contractStartDate: "2023-08-30T23:59:59.999-07:00",
holdbackPercentage: 10,
provinceSharePercentage: 50,
anticipatedFundingAmount: 246,
projectAssetsLifeEndDate: "2023-09-14T23:59:59.999-07:00",
},
isPristine: false,
operation: "ARCHIVE",
formChangeByPreviousFormChangeId: {
newFormData: {
projectId: "Test Project ID",
maxFundingAmount: 200,
provinceSharePercentage: 50,
holdbackPercentage: 10.23,
anticipatedFundingAmount: 300,
proponentCost: 100,
contractStartDate: "2021-01-01T23:59:59.999-07:00",
projectAssetsLifeEndDate:
"2021-12-31T23:59:59.999-07:00",
},
eligibleExpensesToDate: "1.00",
holdbackAmountToDate: "0.10",
netPaymentsToDate: "1.00",
grossPaymentsToDate: "1.00",
calculatedTotalPaymentAmountToDate: "18.4",
proponentsSharePercentage: "91.41791044776119403000",
totalProjectValue: "268",
anticipatedFundingAmountPerFiscalYear: {
edges: [
{
node: {
anticipatedFundingAmount: "1",
fiscalYear: "2023/2024",
},
},
],
},
},
},
Expand All @@ -648,11 +673,13 @@ describe("The Project Funding Agreement Form Summary", () => {
return result;
},
});
componentTestingHelper.renderComponent();
componentTestingHelper.renderComponent(undefined, {
isOnAmendmentsAndOtherRevisionsPage: true,
});

expect(
screen.queryAllByText(/budgets, expenses & payments/i)[1]
).toHaveClass("diffOld");
expect(screen.queryByText(/budgets, expenses & payments/i)).toHaveClass(
"diffOld"
);
});

it("renders the tooltips for the EP form", () => {
Expand Down

0 comments on commit 0fa833e

Please sign in to comment.