Created
          October 9, 2018 02:47 
        
      - 
      
 - 
        
Save rcdexta/89b24fca310d193e5e5dbde1cbf5b85c to your computer and use it in GitHub Desktop.  
    TodoForm.test.js
  
        
  
    
      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 characters
    
  
  
    
  | test('TodoForm should add new item and call onAddItem callback prop', () => { | |
| const addItem = jest.fn() | |
| const {getByTestId} = render(<TodoForm onAddItem={addItem}/>) | |
| let newItem = 'Get Milk' | |
| fireEvent.change(getByTestId('newItemField'), {target: {value: newItem}}) | |
| getByTestId('addBtn').click() | |
| expect(addItem).toBeCalledWith({newItemValue: newItem}) | |
| expect(addItem).toHaveBeenCalledTimes(1); | |
| }) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment