Skip to content

Instantly share code, notes, and snippets.

@busypeoples
Created March 8, 2016 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save busypeoples/7e56a3c62579a7f7b2d1 to your computer and use it in GitHub Desktop.
Save busypeoples/7e56a3c62579a7f7b2d1 to your computer and use it in GitHub Desktop.
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