@@ -2,6 +2,7 @@ import React from "react";
22import faker from "faker" ;
33import { LinkCard } from "./link-card" ;
44import { TestUtils } from "../../tests/test-utils" ;
5+ import { LinkCardTypes } from "../constants/link-card-types" ;
56
67describe ( "LinkCard" , ( ) => {
78 test ( "When default props, renders LinkCard" , ( ) => {
@@ -17,4 +18,42 @@ describe("LinkCard", () => {
1718 //Assert
1819 expect ( getByText ( expected ) ) . not . toBeNull ( ) ;
1920 } ) ;
21+
22+ test ( "When type prop is button, renders LinkCard with 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 ( LinkCardTypes . Button ) [ 0 ] ;
35+
36+ // Assert
37+ expect ( result ) . not . toBeNull ( ) ;
38+ expect ( result . classList ) . toContain ( "c-button" ) ;
39+ expect ( container . innerHTML ) . toContain ( "button" ) ;
40+ } ) ;
41+
42+ test ( "When default props and include icon, renders with class name -with-icon" , ( ) => {
43+ // Arrange
44+ const expected = faker . random . words ( ) ;
45+ const label = faker . random . words ( ) ;
46+
47+ // Act
48+ const { container } = TestUtils . renderWithRouter (
49+ < LinkCard label = { label } includeIcon = { true } >
50+ { expected }
51+ </ LinkCard >
52+ ) ;
53+ const result = container . getElementsByClassName ( "-with-icon" ) [ 0 ] ;
54+
55+ // Assert
56+ expect ( result ) . not . toBeNull ( ) ;
57+ expect ( result . classList ) . toContain ( "-with-icon" ) ;
58+ } ) ;
2059} ) ;
0 commit comments