Skip to content

Commit

Permalink
test: Upadte test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Dec 9, 2024
1 parent a6f1452 commit 3857313
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Fixture() {
handleSubmit={console.log}
title="Pay"
description=""
fn="fee"
fn="application.fee.payable"
color="#efefef"
govPayMetadata={[]}
/>
Expand Down
29 changes: 12 additions & 17 deletions editor.planx.uk/src/@planx/components/Pay/Public/Pay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,10 @@ const flowWithUndefinedFee: Store.Flow = {
_root: {
edges: ["setValue", "pay"],
},
setValue: {
type: TYPES.SetValue,
edges: ["pay"],
data: {
fn: "application.fee.payable",
val: "0",
},
},
pay: {
type: TYPES.Pay,
data: {
fn: "application.fee.typo",
fn: "application.fee.payable",
},
},
};
Expand Down Expand Up @@ -92,22 +84,21 @@ const defaultProps = {
};

describe("Pay component when fee is undefined or £0", () => {
beforeEach(() => {
getState().resetPreview();
});
beforeAll(() => (initialState = getState()));
afterEach(() => act(() => setState(initialState)));

it("Shows an error if fee is undefined", () => {
const handleSubmit = vi.fn();

setState({ flow: flowWithUndefinedFee, breadcrumbs: breadcrumbs });
setState({ flow: flowWithUndefinedFee, breadcrumbs: {} });
expect(getState().computePassport()).toEqual({
data: { "application.fee.payable": ["0"] },
data: { "application.fee.payable": undefined },
});

setup(
<Pay
title="Pay for your application"
fn="application.fee.typo"
fn="application.fee.payable"
handleSubmit={handleSubmit}
govPayMetadata={[]}
/>,
Expand Down Expand Up @@ -456,6 +447,8 @@ describe("Confirm component in information-only mode", () => {
});

describe("the demo user view", () => {
beforeAll(() => (initialState = getState()));

beforeEach(() => {
act(() =>
setState({
Expand All @@ -464,14 +457,16 @@ describe("the demo user view", () => {
);
});

afterEach(() => act(() => setState(initialState)));

it("should render an error when teamSlug is demo", async () => {
const handleSubmit = vi.fn();
const { queryByText } = setup(
<Pay
title="Pay for your application"
fn="application.fee.typo"
fn="application.fee.payable"
handleSubmit={handleSubmit}
govPayMetadata={[]}
{...defaultProps}
/>,
);
const errorHeader = queryByText("GOV.UK Pay is not enabled for demo users");
Expand Down

0 comments on commit 3857313

Please sign in to comment.