Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcenizal committed Mar 9, 2018
1 parent f21d167 commit 4e67ba2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
40 changes: 40 additions & 0 deletions src/components/search_bar/__snapshots__/search_bar.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,43 @@ exports[`SearchBar render - provided query, filters 1`] = `
</EuiFlexItem>
</EuiFlexGroup>
`;

exports[`SearchBar render - tools 1`] = `
<EuiFlexGroup
alignItems="center"
component="div"
gutterSize="m"
justifyContent="flexStart"
responsive={true}
wrap={false}
>
<EuiFlexItem
component="div"
grow={false}
>
<div>
Left
</div>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={true}
>
<EuiSearchBox
incremental={false}
isInvalid={false}
onSearch={[Function]}
placeholder="Search..."
query=""
/>
</EuiFlexItem>
<EuiFlexItem
component="div"
grow={false}
>
<div>
Right
</div>
</EuiFlexItem>
</EuiFlexGroup>
`;
19 changes: 14 additions & 5 deletions src/components/search_bar/search_bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { shallow } from 'enzyme';
import { EuiSearchBar } from './search_bar';

describe('SearchBar', () => {

test('render - no config, no query', () => {

const props = {
...requiredProps,
onChange: () => {}
Expand All @@ -17,11 +15,24 @@ describe('SearchBar', () => {
);

expect(component).toMatchSnapshot();
});

test('render - tools', () => {
const props = {
...requiredProps,
onChange: () => {},
toolsLeft: <div>Left</div>,
toolsRight: <div>Right</div>,
};

const component = shallow(
<EuiSearchBar {...props} />
);

expect(component).toMatchSnapshot();
});

test('render - no query, custom box placeholder and incremental', () => {

const props = {
...requiredProps,
config: {
Expand All @@ -41,7 +52,6 @@ describe('SearchBar', () => {
});

test('render - provided query, filters', () => {

const props = {
...requiredProps,
filters: [
Expand All @@ -67,5 +77,4 @@ describe('SearchBar', () => {

expect(component).toMatchSnapshot();
});

});

0 comments on commit 4e67ba2

Please sign in to comment.