File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 11import React from "react" ;
2+ import { TextArea } from "./text-area" ;
3+ import uuid from "uuid" ;
4+ import { render , fireEvent } from "@testing-library/react" ;
5+ import faker from "faker" ;
26
37describe ( "TextArea" , ( ) => {
4- test . skip ( "TODO - https://github.com/AndcultureCode/AndcultureCode.JavaScript.React.Components/issues/10" , ( ) => { } ) ;
8+ test ( "when default props, renders text area" , ( ) => {
9+ // Arrange
10+ const expected = faker . random . word ( ) ;
11+
12+ // Act
13+ const { getByTestId } = render (
14+ < TextArea id = { uuid ( ) } onChange = { ( ) => { } } testId = { expected } />
15+ ) ;
16+
17+ // Assert
18+ expect ( getByTestId ( expected ) ) . not . toBeNil ( ) ;
19+ } ) ;
20+
21+ test ( "when onChange set, calls handler upon change" , ( ) => {
22+ // Arrange
23+ let isChecked = false ;
24+ const handleChange = ( ) => ( isChecked = true ) ;
25+ const expected = faker . random . word ( ) ;
26+
27+ // Act
28+ const { getByTestId } = render (
29+ < TextArea id = { expected } onChange = { handleChange } testId = { expected } />
30+ ) ;
31+
32+ fireEvent . change ( getByTestId ( expected ) , {
33+ target : { value : faker . random . word ( ) } ,
34+ } ) ;
35+
36+ // Assert
37+ expect ( isChecked ) . toBeTrue ( ) ;
38+ } ) ;
539} ) ;
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ const TextArea: React.FC<TextAreaProps> = (props: TextAreaProps) => {
4141
4242 return (
4343 < textarea
44- data-test-id = { testId }
44+ data-testid = { testId }
4545 disabled = { disabled }
4646 id = { id }
4747 maxLength = { maxLength }
You can’t perform that action at this time.
0 commit comments