mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-11-13 03:35:52 +01:00
fd6769850a
* fix(webui): search crash on ' ' as a value #898 * chore(test): add unit test cases for Home component - test case for handleSearchInput function
40 lines
909 B
JavaScript
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());
|
|
});
|
|
});
|