From e432847e1a1a379bd3d824c541c818167d296a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Sun, 1 Dec 2024 13:42:02 +0000 Subject: [PATCH] test: Ensure a realistic mock passport is used --- .../Public/FeeBreakdown/useFeeBreakdown.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/Pay/Public/FeeBreakdown/useFeeBreakdown.test.ts b/editor.planx.uk/src/@planx/components/Pay/Public/FeeBreakdown/useFeeBreakdown.test.ts index 47434fc94e..b0282477b1 100644 --- a/editor.planx.uk/src/@planx/components/Pay/Public/FeeBreakdown/useFeeBreakdown.test.ts +++ b/editor.planx.uk/src/@planx/components/Pay/Public/FeeBreakdown/useFeeBreakdown.test.ts @@ -21,6 +21,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.calculated": 1000, "application.fee.payable": 800, "application.fee.payable.vat": 160, + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -44,6 +45,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.calculated": [1000], "application.fee.payable": [800], "application.fee.payable.vat": [160], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -69,6 +71,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.payable.vat": 160, "application.fee.reduction.reasonOne": ["true"], "application.fee.reduction.reasonTwo": ["true"], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -88,6 +91,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.payable.vat": 160, "application.fee.reduction.reasonOne": ["false"], "application.fee.reduction.reasonTwo": ["false"], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -104,6 +108,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.payable.vat": 160, "application.fee.exemption.reasonOne": ["true"], "application.fee.exemption.reasonTwo": ["true"], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -123,6 +128,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.payable.vat": 160, "application.fee.exemption.reasonOne": ["false"], "application.fee.exemption.reasonTwo": ["false"], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -135,7 +141,9 @@ describe("useFeeBreakdown() hook", () => { describe("invalid inputs", () => { it("returns undefined for missing data", () => { - const mockPassportData = {}; + const mockPassportData = { + "some.other.fields": ["abc", "xyz"], + }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -148,6 +156,7 @@ describe("useFeeBreakdown() hook", () => { const mockPassportData = { "application.fee.calculated": [1000], "application.fee.payable.vat": [160], + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -162,6 +171,7 @@ describe("useFeeBreakdown() hook", () => { "application.fee.calculated": "some string", "application.fee.payable": [800, 700], "application.fee.payable.vat": false, + "some.other.fields": ["abc", "xyz"], }; vi.mocked(useStore).mockReturnValue([mockPassportData, "test-session"]); @@ -172,7 +182,9 @@ describe("useFeeBreakdown() hook", () => { }); it("calls Airbrake if invalid inputs are provided", () => { - const mockPassportData = {}; + const mockPassportData = { + "some.other.fields": ["abc", "xyz"], + }; const mockSessionId = "test-session"; vi.mocked(useStore).mockReturnValue([mockPassportData, mockSessionId]);