|
| 1 | +import faker from "faker"; |
| 2 | +import React from "react"; |
| 3 | +import { render } from "@testing-library/react"; |
| 4 | +import { ToastTemplates } from "./toast-templates"; |
| 5 | + |
1 | 6 | describe("ToastTemplates", () => { |
2 | | - test.skip("TODO: Backfill tests for issue https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/34", () => {}); |
| 7 | + test("when toast type is info, renders info toast", () => { |
| 8 | + // Arrange |
| 9 | + const toastContent = faker.random.word(); |
| 10 | + const toast = ToastTemplates.info(toastContent); |
| 11 | + |
| 12 | + // Act |
| 13 | + const { getByText } = render(<React.Fragment>{toast}</React.Fragment>); |
| 14 | + |
| 15 | + // Assert |
| 16 | + expect(getByText(toastContent)).not.toBeNil(); |
| 17 | + }); |
| 18 | + |
| 19 | + test("when toast type is error, renders error toast", () => { |
| 20 | + // Arrange |
| 21 | + const toastContent = faker.random.word(); |
| 22 | + const toast = ToastTemplates.error(toastContent); |
| 23 | + |
| 24 | + // Act |
| 25 | + const { getByText } = render(<React.Fragment>{toast}</React.Fragment>); |
| 26 | + |
| 27 | + // Assert |
| 28 | + expect(getByText(toastContent)).not.toBeNil(); |
| 29 | + }); |
| 30 | + |
| 31 | + test("when toast type is success, renders success toast", () => { |
| 32 | + // Arrange |
| 33 | + const toastContent = faker.random.word(); |
| 34 | + const toast = ToastTemplates.success(toastContent); |
| 35 | + |
| 36 | + // Act |
| 37 | + const { getByText } = render(<React.Fragment>{toast}</React.Fragment>); |
| 38 | + |
| 39 | + // Assert |
| 40 | + expect(getByText(toastContent)).not.toBeNil(); |
| 41 | + }); |
| 42 | + |
| 43 | + test("when toast type is warning, renders warning toast", () => { |
| 44 | + // Arrange |
| 45 | + const toastContent = faker.random.word(); |
| 46 | + const toast = ToastTemplates.warning(toastContent); |
| 47 | + |
| 48 | + // Act |
| 49 | + const { getByText } = render(<React.Fragment>{toast}</React.Fragment>); |
| 50 | + |
| 51 | + // Assert |
| 52 | + expect(getByText(toastContent)).not.toBeNil(); |
| 53 | + }); |
3 | 54 | }); |
0 commit comments