|
| 1 | +import React from "react"; |
| 2 | +import faker from "faker"; |
| 3 | +import { LinkCard, LinkCardIconClassName } from "./link-card"; |
| 4 | +import { TestUtils } from "../../tests/test-utils"; |
| 5 | +import { LinkCardTypes } from "../constants/link-card-types"; |
| 6 | + |
1 | 7 | describe("LinkCard", () => { |
2 | | - test.skip("TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/36", () => {}); |
| 8 | + test("when default props, renders LinkCard", () => { |
| 9 | + // Arrange |
| 10 | + const expected = faker.random.words(); |
| 11 | + const label = faker.random.words(); |
| 12 | + |
| 13 | + // Act |
| 14 | + const { getByText } = TestUtils.renderWithRouter( |
| 15 | + <LinkCard label={label}>{expected}</LinkCard> |
| 16 | + ); |
| 17 | + |
| 18 | + //Assert |
| 19 | + expect(getByText(expected)).not.toBeNil(); |
| 20 | + }); |
| 21 | + |
| 22 | + test(`when type prop is button, renders ${LinkCardTypes.Button}`, () => { |
| 23 | + // Arrange |
| 24 | + const expected = faker.random.words(); |
| 25 | + const label = faker.random.words(); |
| 26 | + const type = LinkCardTypes.Button; |
| 27 | + |
| 28 | + // Act |
| 29 | + const { container } = TestUtils.renderWithRouter( |
| 30 | + <LinkCard label={label} type={type}> |
| 31 | + {expected} |
| 32 | + </LinkCard> |
| 33 | + ); |
| 34 | + const result = container.getElementsByTagName("button")[0]; |
| 35 | + |
| 36 | + // Assert |
| 37 | + expect(result).not.toBeNil(); |
| 38 | + }); |
| 39 | + |
| 40 | + test(`when default props and include icon, renders with class name ${LinkCardIconClassName}`, () => { |
| 41 | + // Arrange |
| 42 | + const expected = faker.random.words(); |
| 43 | + const label = faker.random.words(); |
| 44 | + |
| 45 | + // Act |
| 46 | + const { container } = TestUtils.renderWithRouter( |
| 47 | + <LinkCard label={label} includeIcon={true}> |
| 48 | + {expected} |
| 49 | + </LinkCard> |
| 50 | + ); |
| 51 | + const result = container.getElementsByClassName( |
| 52 | + LinkCardIconClassName |
| 53 | + )[0]; |
| 54 | + |
| 55 | + // Assert |
| 56 | + expect(result).not.toBeNil(); |
| 57 | + expect(result.classList).toContain(LinkCardIconClassName); |
| 58 | + }); |
3 | 59 | }); |
0 commit comments