Skip to content

Commit

Permalink
fix(archive): should not trigger search when input length is less tha…
Browse files Browse the repository at this point in the history
…n 2 (#1154)
  • Loading branch information
Mingze authored and mergify[bot] committed Jan 17, 2020
1 parent 5c6cc96 commit 9937133
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/viewers/archive/ArchiveExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ArchiveExplorer extends React.Component {
handleSearch = query =>
this.setState({
searchQuery: query,
view: query.trim() ? VIEW_SEARCH : VIEW_FOLDER,
view: query.trim().length >= 2 ? VIEW_SEARCH : VIEW_FOLDER,
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('lib/viewers/archive/ArchiveExplorer', () => {
});

describe('handleSearch()', () => {
it('should set correct state when search query is not empty', () => {
it('should set correct state when search query longer than 1 letter', () => {
const component = getComponent({ filename, itemCollection: data });

component.instance().handleSearch('test');
Expand All @@ -149,6 +149,10 @@ describe('lib/viewers/archive/ArchiveExplorer', () => {
component.instance().handleSearch(' ');
expect(component.state().searchQuery).to.equal(' ');
expect(component.state().view).to.equal(VIEWS.VIEW_FOLDER);

component.instance().handleSearch('a');
expect(component.state().searchQuery).to.equal('a');
expect(component.state().view).to.equal(VIEWS.VIEW_FOLDER);
});
});

Expand Down

0 comments on commit 9937133

Please sign in to comment.