Created
October 12, 2018 04:27
-
-
Save juddey/220c62f60198f517d6663afa5ea7a29c to your computer and use it in GitHub Desktop.
Centre-Selector-Unit-Test
This file contains 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
import React from 'react' | |
import { render } from 'testUtils' | |
import { fireEvent } from 'react-testing-library' | |
import CentreSelector from './CentreSelector' | |
const centres = [ | |
{ | |
centre_id: '123', | |
centre_name: 'Demo Centre' | |
}, | |
{ | |
centre_id: '456', | |
centre_name: 'Demo Centre II' | |
} | |
] | |
test('invokes the onCloseHandler', async () => { | |
const spy = jest.fn() | |
const { getByText } = render( | |
<CentreSelector | |
value={centres[0].centre_id} | |
centres={centres} | |
onChange={spy} | |
/> | |
) | |
fireEvent.click(getByText('Demo Centre')) | |
fireEvent.click(getByText('Demo Centre II')) | |
expect(spy).toHaveBeenCalledTimes(1) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment