2023-04-18 19:38:41 +08:00
|
|
|
/*
|
2024-09-09 21:57:16 +08:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-04-18 19:38:41 +08:00
|
|
|
Copyright 2023 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 21:57:16 +08:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2023-04-18 19:38:41 +08:00
|
|
|
*/
|
|
|
|
|
2024-10-15 00:11:58 +08:00
|
|
|
import { render, RenderResult } from "jest-matrix-react";
|
2023-04-18 19:38:41 +08:00
|
|
|
import React, { ComponentProps } from "react";
|
|
|
|
|
2024-10-15 21:57:26 +08:00
|
|
|
import GenericToast from "../../../../../src/components/views/toasts/GenericToast";
|
2023-04-18 19:38:41 +08:00
|
|
|
|
|
|
|
const renderGenericToast = (props: Partial<ComponentProps<typeof GenericToast>> = {}): RenderResult => {
|
|
|
|
const propsWithDefaults = {
|
2024-07-30 20:57:15 +08:00
|
|
|
primaryLabel: "Accept",
|
2023-04-18 19:38:41 +08:00
|
|
|
description: <div>Description</div>,
|
2024-07-30 20:57:15 +08:00
|
|
|
onPrimaryClick: () => {},
|
|
|
|
onSecondaryClick: () => {},
|
|
|
|
secondaryLabel: "Reject",
|
2023-04-18 19:38:41 +08:00
|
|
|
...props,
|
|
|
|
};
|
|
|
|
|
|
|
|
return render(<GenericToast {...propsWithDefaults} />);
|
|
|
|
};
|
|
|
|
|
|
|
|
describe("GenericToast", () => {
|
|
|
|
it("should render as expected with detail content", () => {
|
|
|
|
const { asFragment } = renderGenericToast();
|
|
|
|
expect(asFragment()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should render as expected without detail content", () => {
|
|
|
|
const { asFragment } = renderGenericToast({
|
|
|
|
detail: "Detail",
|
|
|
|
});
|
|
|
|
expect(asFragment()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|