Created
March 8, 2016 23:37
-
-
Save busypeoples/7e56a3c62579a7f7b2d1 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 { shallow, mount, render } from 'enzyme' | |
import Root, { SearchBar, ReleaseTable, Release } from '../src/Root' | |
describe('<SearchBar>', () => { | |
let onSearch; | |
beforeEach(() => { | |
onSearch = jasmine.createSpy('onSearch'); | |
}); | |
it('calls onSearch when search text changes', () => { | |
let props = { searchText: '', noOutOfPrint: false, onSearch }; | |
let search = mount(<SearchBar { ...props } />); | |
let input = search.find('#searchFilter'); | |
input.get(0).value = 'foobar'; | |
input.simulate('change'); | |
expect(onSearch).toHaveBeenCalledWith('foobar', false); | |
}); | |
it('calls onSearch when no out print is checked', () => { | |
let props = { searchText: '', noOutOfPrint: false, onSearch }; | |
let search = mount(<SearchBar { ...props } />); | |
let input = search.find('#noOutOfPrint'); | |
input.get(0).checked = true; | |
input.simulate('change', {target: { checked: true }}); | |
expect(onSearch).toHaveBeenCalledWith('', true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment