-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix(webui): search crash on ' ' as a value #898 * chore(test): add unit test cases for Home component - test case for handleSearchInput function
- Loading branch information
1 parent
4112587
commit fd67698
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Home Component | ||
*/ | ||
|
||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Home from '../../../../src/webui/modules/home/index'; | ||
|
||
describe('<Home /> Component', () => { | ||
let wrapper; | ||
|
||
beforeEach(() => { | ||
wrapper = mount(<Home />); | ||
}); | ||
|
||
it('handleSearchInput - should match the search query', () => { | ||
const { handleSearchInput } = wrapper.instance(); | ||
const result = 'test query string one'; | ||
const input = { | ||
target: { | ||
value: result | ||
} | ||
}; | ||
handleSearchInput(input); | ||
expect(wrapper.state('query')).toBe(result); | ||
}); | ||
|
||
it('handleSearchInput - should match the trimmed search query', () => { | ||
const { handleSearchInput } = wrapper.instance(); | ||
const result = ' '; | ||
const input = { | ||
target: { | ||
value: result | ||
} | ||
}; | ||
handleSearchInput(input); | ||
expect(wrapper.state('query')).toBe(result.trim()); | ||
}); | ||
}); |