diff --git a/src/webui/modules/home/index.js b/src/webui/modules/home/index.js
index 8a916fa10..edc86850a 100644
--- a/src/webui/modules/home/index.js
+++ b/src/webui/modules/home/index.js
@@ -89,7 +89,7 @@ export default class Home extends React.Component {
handleSearchInput(e) {
this.setState({
- query: e.target.value
+ query: e.target.value.trim()
});
}
diff --git a/test/unit/webui/modules/home.spec.js b/test/unit/webui/modules/home.spec.js
new file mode 100644
index 000000000..2f28133bc
--- /dev/null
+++ b/test/unit/webui/modules/home.spec.js
@@ -0,0 +1,39 @@
+/**
+ * Home Component
+ */
+
+import React from 'react';
+import { mount } from 'enzyme';
+import Home from '../../../../src/webui/modules/home/index';
+
+describe(' Component', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = mount();
+ });
+
+ 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());
+ });
+});