Skip to content

Commit

Permalink
Fix search tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Oct 20, 2016
1 parent ed061df commit 971968a
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ describe("test the SearchBar", () => {

it('test search and reset on enter', () => {
var TestUtils = React.addons.TestUtils;
var tb;
const testHandlers = {
onSearchHandler: (text) => {return text; },
onSearchResetHandler: () => {}
onSearchHandler: (text) => { return text; },
onSearchResetHandler: () => {},
onSearchTextChangeHandler: (text) => { tb.setProps({searchText: text}); }
};

const spy = expect.spyOn(testHandlers, 'onSearchHandler');
const spyReset = expect.spyOn(testHandlers, 'onSearchResetHandler');
var tb = ReactDOM.render(<SearchBar delay={0} typeAhead={false} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler}/>, document.getElementById("container"));
tb = ReactDOM.render(<SearchBar delay={0} typeAhead={false} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler} onSearchTextChange={testHandlers.onSearchTextChangeHandler}/>, document.getElementById("container"));
let input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(tb, "input")[0]);

expect(input).toExist();
Expand All @@ -53,13 +55,16 @@ describe("test the SearchBar", () => {

it('test search and reset buttons', () => {
var TestUtils = React.addons.TestUtils;
var tb;
const testHandlers = {
onSearchHandler: (text) => {return text; },
onSearchResetHandler: () => {}
onSearchHandler: (text) => { return text; },
onSearchResetHandler: () => { tb.setProps({searchText: ""}); },
onSearchTextChangeHandler: (text) => { tb.setProps({searchText: text}); }
};

const spyReset = expect.spyOn(testHandlers, 'onSearchResetHandler');
var tb = ReactDOM.render(<SearchBar delay={0} typeAhead={false} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler}/>, document.getElementById("container"));
spyReset.andCallThrough();
tb = ReactDOM.render(<SearchBar delay={0} typeAhead={false} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler} onSearchTextChange={testHandlers.onSearchTextChangeHandler}/>, document.getElementById("container"));
let input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(tb, "input")[0]);
// test reset button
expect(input).toExist();
Expand All @@ -75,11 +80,13 @@ describe("test the SearchBar", () => {

it('test typeahead', (done) => {
var TestUtils = React.addons.TestUtils;
var tb;
const testHandlers = {
onSearchHandler: (text) => {return text; }
onSearchHandler: (text) => {return text; },
onSearchTextChangeHandler: (text) => { tb.setProps({searchText: text}); }
};
const spy = expect.spyOn(testHandlers, 'onSearchHandler');
var tb = ReactDOM.render(<SearchBar delay={0} typeAhead={true} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler}/>, document.getElementById("container"));
tb = ReactDOM.render(<SearchBar delay={0} typeAhead={true} onSearch={testHandlers.onSearchHandler} onSearchReset={testHandlers.onSearchResetHandler} onSearchTextChange={testHandlers.onSearchTextChangeHandler}/>, document.getElementById("container"));
let input = ReactDOM.findDOMNode(TestUtils.scryRenderedDOMComponentsWithTag(tb, "input")[0]);

expect(input).toExist();
Expand Down

0 comments on commit 971968a

Please sign in to comment.