Last active
July 7, 2020 03:13
-
-
Save damusnet/f15a3c23162012be66d7f0b36c930734 to your computer and use it in GitHub Desktop.
Revisions
-
damusnet revised this gist
Jul 7, 2020 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ const App = () => { return ( <div> You clicked me {counter} times! <ClickMe counter={counter} setCounter={setCounter} /> </div> ) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ describe('<ClickMe />', () => { expect(component.toJSON()).toMatchSnapshot() act(() => { component.root.findByProps({ children: 'Click Me!' }).props.onClick() }) expect(mockFn).toHaveBeenCalledWith(1) -
damusnet renamed this gist
Jul 7, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ describe('<ClickMe />', () => { const mockFn = jest.fn() const component = TestRenderer.create( <ClickMe counter={0} setCounter={mockFn} />, ) expect(component.toJSON()).toMatchSnapshot() @@ -14,6 +14,6 @@ describe('<ClickMe />', () => { component.root.findByProps({ children: 'Click Me!' }).props.onClick(); }) expect(mockFn).toHaveBeenCalledWith(1) }) }) -
damusnet created this gist
Jul 7, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ const App = () => { const [counter, setCounter] = React.useState(0) return ( <div> You clicked me {counter}! <ClickMe counter={counter} setCounter={setCounter} /> </div> ) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ const ClickMe = ({ counter, setCounter }) => { return ( <button type="button" onClick={() => setCounter(counter + 1)}> Click me! </button> ) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import TestRenderer, { act } from 'react-test-renderer'; describe('<ClickMe />', () => { it('should render properly', () => { const mockFn = jest.fn() const component = TestRenderer.create( <ClickMe counter={0} setCounter={mockFn}>/>, ) expect(component.toJSON()).toMatchSnapshot() act(() => { component.root.findByProps({ children: 'Click Me!' }).props.onClick(); }) expect(mockFn).toHaveBeenCalledWith(2) }) })