diff --git a/package.json b/package.json
index 52437ef2..bc3ca508 100644
--- a/package.json
+++ b/package.json
@@ -58,6 +58,7 @@
"prop-types": "15.6.0",
"react-input-autosize": "2.2.1",
"react-motion": "0.5.2",
+ "react-required-if": "^1.0.3",
"react-resize-aware": "2.7.0",
"react-router": "3.2.0"
},
@@ -65,7 +66,7 @@
"babel-cli": "^6.18.0",
"babel-core": "6.18.2",
"babel-eslint": "8.2.1",
- "babel-jest": "^17.0.2",
+ "babel-jest": "23.6.0",
"babel-loader": "6.2.8",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-styled-components": "^1.3.0",
@@ -95,9 +96,8 @@
"font-awesome-webpack": "0.0.4",
"highlight.js": "9.12.0",
"html-webpack-plugin": "2.24.1",
- "jest": "20.0.4",
- "jest-cli": "19.0.2",
- "jest-styled-components": "4.4.1",
+ "jest": "23.6.0",
+ "jest-styled-components": "6.2.0",
"json-loader": "0.5.4",
"less": "2.7.2",
"lodash": "4.17.10",
diff --git a/src/components/Code/Code.test.js b/src/components/Code/Code.test.js
index 5daee57a..2e0e6f9f 100644
--- a/src/components/Code/Code.test.js
+++ b/src/components/Code/Code.test.js
@@ -1,13 +1,10 @@
import React from 'react';
-import enzyme, { shallow, mount } from 'enzyme';
-import Adapter from 'enzyme-adapter-react-16';
+import { shallow, mount } from 'enzyme';
import { withTheme } from '../../utils/theme';
import Code from '.';
-enzyme.configure({ adapter: new Adapter() });
-
document.execCommand = () => {};
document.getSelection = () => ({
toString: () => '',
diff --git a/src/components/Code/__snapshots__/Code.test.js.snap b/src/components/Code/__snapshots__/Code.test.js.snap
index 8c43c661..584c03f7 100644
--- a/src/components/Code/__snapshots__/Code.test.js.snap
+++ b/src/components/Code/__snapshots__/Code.test.js.snap
@@ -40,21 +40,21 @@ exports[`
should render multi line function correctly with multiCommand=
>
sudo curl -l git.io/scope -o /usr/local/bin/scope
-
+
sudo chmod a+x /usr/local/bin/scope
-
+
scope launch https://yjsjsubdx1h8un1f858gp7to8d51zdre@frontend.dev.weave.works
-
+
@@ -86,7 +86,7 @@ exports[`
should render multi line jsx correctly with multiCommand=true
sudo curl -L git.io/scope -o /usr/local/bin/scope
-
+
should render multi line jsx correctly with multiCommand=true
sudo chmod a+x /usr/local/bin/scope
-
+
should render multi line jsx correctly with multiCommand=true
https://yjsjsubdx1h8un1f858gp7to8d51zdre@frontend.dev.weave.works
-
+
@@ -136,21 +136,21 @@ exports[`
should render multi line string correctly with multiCommand=tr
>
sudo curl -l git.io/scope -o /usr/local/bin/scope
-
+
sudo chmod a+x /usr/local/bin/scope
-
+
scope launch https://yjsjsubdx1h8un1f858gp7to8d51zdre@frontend.dev.weave.works
-
+
diff --git a/src/components/DataTable/__snapshots__/DataTable.test.js.snap b/src/components/DataTable/__snapshots__/DataTable.test.js.snap
index 64ddc267..8209b2be 100644
--- a/src/components/DataTable/__snapshots__/DataTable.test.js.snap
+++ b/src/components/DataTable/__snapshots__/DataTable.test.js.snap
@@ -49,7 +49,6 @@ exports[`DataTable snapshots renders an element instead of a label 1`] = `
', () => {
let props;
let wrapper;
@@ -66,6 +63,8 @@ describe('', () => {
it('should remove validation message from the DOM when hideValidationMessage=true', () => {
props = {
hideValidationMessage: true,
+ // https://github.com/styled-components/jest-styled-components/issues/189
+ message: 'Derp!',
};
wrapper = mount(withTheme());
diff --git a/src/components/Input/__snapshots__/Input.test.js.snap b/src/components/Input/__snapshots__/Input.test.js.snap
index 92d16a6c..4a8c439c 100644
--- a/src/components/Input/__snapshots__/Input.test.js.snap
+++ b/src/components/Input/__snapshots__/Input.test.js.snap
@@ -266,7 +266,7 @@ exports[` should render correctly 1`] = `
should render correctly 1`] = `
inputRef={[Function]}
label="Hi"
message="Doh!"
- onChange={[Function]}
+ onChange={[MockFunction]}
textarea={false}
valid={false}
>
@@ -294,7 +294,7 @@ exports[` should render correctly 1`] = `
className="c1"
>
props.filters.length > 0),
onFocus: PropTypes.func,
onBlur: PropTypes.func,
};
@@ -230,10 +231,8 @@ Search.defaultProps = {
placeholder: 'search',
disabled: false,
filters: [],
+ onFilterSelect: noop,
onPin: noop,
- onFilterSelect: () => {
- throw new Error('Please provide an onFilterSelect(value) callback!');
- },
onFocus: noop,
onBlur: noop,
};
diff --git a/src/components/Search/Search.test.js b/src/components/Search/Search.test.js
index bdcd58e1..83aca360 100644
--- a/src/components/Search/Search.test.js
+++ b/src/components/Search/Search.test.js
@@ -13,20 +13,36 @@ describe('', () => {
describe('snapshots', () => {
it('renders empty', () => {
const tree = renderer
- .create(withTheme())
+ .create(
+ withTheme(
+
+ )
+ )
.toJSON();
expect(tree).toMatchSnapshot();
});
+
it('renders a search string', () => {
const tree = renderer
.create(
withTheme(
-
+
)
)
.toJSON();
expect(tree).toMatchSnapshot();
});
+
it('renders a group of terms', () => {
const tree = renderer
.create(
@@ -35,12 +51,14 @@ describe('', () => {
query=""
pinnedTerms={['deployments', 'default']}
onChange={noop}
+ onFilterSelect={noop}
/>
)
)
.toJSON();
expect(tree).toMatchSnapshot();
});
+
it('renders filters', () => {
const tree = renderer
.create(
@@ -49,6 +67,7 @@ describe('', () => {
query=""
pinnedTerms={[]}
onChange={noop}
+ onFilterSelect={noop}
filters={[
{ value: 'automated', label: 'Automated' },
{ value: 'locked', label: 'Locked' },
@@ -60,15 +79,24 @@ describe('', () => {
expect(tree).toMatchSnapshot();
});
});
+
it('returns search terms', () => {
const spy = createSpy();
const search = mount(
- withTheme()
+ withTheme(
+
+ )
);
const $input = search.find('input');
$input.simulate('change', { target: { value: 'myterm' } });
expect(spy.calls[0].arguments).toEqual(['myterm', ['a']]);
});
+
it('calls the onFilterSelect prop with selected filter value', () => {
const spy = createSpy();
const search = mount(
@@ -99,40 +127,24 @@ describe('', () => {
.simulate('click');
expect(spy.calls[0].arguments).toEqual(['automated']);
});
+
it('clears terms', () => {
const spy = createSpy();
- const search = mount(
- withTheme()
- );
- // Remove the 'a' search term
- search
- .find('.remove-term')
- .first()
- .simulate('click');
- expect(spy.calls[0].arguments).toEqual(['', ['b']]);
- });
- it('should raise an error if you forget to provide an onFilterSelect callback', () => {
const search = mount(
withTheme(
)
);
+ // Remove the 'a' search term
search
- .find('.dropdown-toggle')
+ .find('.remove-term')
.first()
.simulate('click');
-
- expect(() =>
- // select a filter
- search
- .find('.dropdown-item')
- .first()
- .simulate('click')
- ).toThrow();
+ expect(spy.calls[0].arguments).toEqual(['', ['b']]);
});
});
diff --git a/src/components/Search/__snapshots__/Search.test.js.snap b/src/components/Search/__snapshots__/Search.test.js.snap
index 7e41ce77..ac14a527 100644
--- a/src/components/Search/__snapshots__/Search.test.js.snap
+++ b/src/components/Search/__snapshots__/Search.test.js.snap
@@ -232,9 +232,7 @@ exports[` snapshots renders a group of terms 1`] = `
- |