Created
March 18, 2019 23:42
-
-
Save ajcrites/837ed043550d28c9b7e0051ddd06dfc7 to your computer and use it in GitHub Desktop.
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, fireEvent, cleanup } from 'react-testing-library'; | |
import { ColorToolContext } from '~/ColorToolContext'; | |
import { updateHex } from '~/colorReducer'; | |
import { HexInput } from '../HexInput'; | |
describe('HexInput component', () => { | |
test('dispatch updated hex value when input changes', () => { | |
const testHex = '#abcef'; | |
const state = { | |
hex: '', | |
rgba: [0, 0, 0, 0], | |
dispatch: jest.fn(), | |
}; | |
const { container } = render(( | |
<ColorToolContext.Provider value={state}> | |
<HexInput /> | |
</ColorToolContext.Provider> | |
)); | |
const input = container.querySelector('input'); | |
fireEvent.change(input, { target: { value: testHex } }); | |
expect(state.dispatch).toHaveBeenCalledWith(updateHex(testHex)); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment