Skip to content

Commit 295e0b2

Browse files
committed
Added tests for atoms submit button to fix issue #8
1 parent 325c24b commit 295e0b2

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
import React from "react";
2+
import { render } from "@testing-library/react";
3+
import { SubmitButton } from "./submit-button";
4+
import faker from "faker";
5+
import { ButtonStyles } from "../constants/button-styles";
26

37
describe("SubmitButton", () => {
4-
test.skip("TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/8", () => {});
8+
test("when default props, renders default buttonText", async () => {
9+
// Arrange
10+
const expected = "Submit";
11+
12+
// Act
13+
const { getByText } = render(<SubmitButton />);
14+
15+
// Assert
16+
expect(getByText(expected)).not.toBeNull();
17+
});
18+
test("when buttonText provided, renders supplied buttonText", async () => {
19+
// Arrange
20+
const expected = faker.random.words();
21+
22+
// Act
23+
const { getByText } = render(<SubmitButton buttonText={expected} />);
24+
25+
// Assert
26+
expect(getByText(expected)).not.toBeNull();
27+
});
28+
29+
test("when cssClassName provided, renders with className set", async () => {
30+
// Arrange
31+
const expected = ButtonStyles.Anchor;
32+
33+
// Act
34+
const { container } = render(<SubmitButton cssClassName={expected} />);
35+
36+
// Assert
37+
expect(container.firstChild.className).toContain(expected);
38+
});
539
});

0 commit comments

Comments
 (0)