1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/unit/webui/modules/home.spec.js
Ashish Surana fd6769850a fix(webui): search crash on ' ' as a value #898 (#902)
* fix(webui): search crash on ' ' as a value #898

* chore(test): add unit test cases for Home component

  - test case for handleSearchInput function
2018-08-12 22:25:47 +02:00

40 lines
909 B
JavaScript

/**
* 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());
});
});