Skip to content

Commit bd4d744

Browse files
author
Said Shah
committed
Added tests for heading
1 parent 61ffc08 commit bd4d744

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
import React from "react";
2+
import faker from "faker";
3+
import { Heading } from "./heading";
4+
import { render } from "@testing-library/react";
25

36
describe("Heading", () => {
4-
test.skip("TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/14", () => {});
7+
test("when default props, renders heading", () => {
8+
// Assert
9+
const expected = faker.random.words();
10+
11+
// Act
12+
const { getByText } = render(<Heading>{expected}</Heading>);
13+
14+
// Assert
15+
expect(getByText(expected)).not.toBeNil();
16+
});
17+
18+
test("when given cssClassName prop, renders with given class name", () => {
19+
// Act
20+
const randomText = faker.random.words();
21+
const testClassName = "testClassName";
22+
23+
// Arrange
24+
const { container } = render(
25+
<Heading cssClassName={testClassName}>{randomText}</Heading>
26+
);
27+
const result = container.getElementsByClassName(testClassName);
28+
29+
// Assert
30+
expect(result[0]).not.toBeNil();
31+
});
532
});

0 commit comments

Comments
 (0)