Skip to content

Commit 3c6bfe0

Browse files
committed
Add Jest-specific linting rules
Adding this caught a couple of important things: - The sound integration tests have a `.only` in them - The project-saver-hoc tests had two tests with the same description, causing possible confusion if that test broke
1 parent d7e3386 commit 3c6bfe0

File tree

7 files changed

+77
-13
lines changed

7 files changed

+77
-13
lines changed

package-lock.json

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"eslint": "^5.0.1",
5757
"eslint-config-scratch": "^5.0.0",
5858
"eslint-plugin-import": "^2.8.0",
59+
"eslint-plugin-jest": "^22.14.1",
5960
"eslint-plugin-react": "^7.12.4",
6061
"file-loader": "2.0.0",
6162
"get-float-time-domain-data": "0.1.0",

test/.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module.exports = {
2-
extends: ['scratch/react', 'scratch/es6'],
2+
extends: ['scratch/react', 'scratch/es6', 'plugin:jest/recommended'],
33
env: {
44
browser: true,
55
jest: true
66
},
7+
plugins: ['jest'],
78
rules: {
89
'react/prop-types': 0
910
}

test/helpers/selenium-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; // eslint-disable-line no-undef
1+
jest.setTimeout(30000); // eslint-disable-line no-undef
22

33
import bindAll from 'lodash.bindall';
44
import 'chromedriver'; // register path

test/unit/containers/slider-prompt.test.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('Slider Prompt Container', () => {
5555
const componentProps = wrapper.find(SliderPromptComponent).props();
5656
componentProps.onChangeMin({target: {value: '1.0'}});
5757
componentProps.onOk();
58-
expect(onOk).toBeCalledWith(1, 100, false);
58+
expect(onOk).toHaveBeenCalledWith(1, 100, false);
5959
});
6060

6161
test('Entering integers submits with isDiscrete=true', () => {
@@ -72,7 +72,7 @@ describe('Slider Prompt Container', () => {
7272
componentProps.onChangeMin({target: {value: '1'}});
7373
componentProps.onChangeMax({target: {value: '2'}});
7474
componentProps.onOk();
75-
expect(onOk).toBeCalledWith(1, 2, true);
75+
expect(onOk).toHaveBeenCalledWith(1, 2, true);
7676
});
7777

7878
test('Enter button submits the form', () => {
@@ -89,7 +89,7 @@ describe('Slider Prompt Container', () => {
8989
componentProps.onChangeMin({target: {value: '1'}});
9090
componentProps.onChangeMax({target: {value: '2'}});
9191
componentProps.onKeyPress({key: 'Enter'});
92-
expect(onOk).toBeCalledWith(1, 2, true);
92+
expect(onOk).toHaveBeenCalledWith(1, 2, true);
9393
});
9494

9595
test('Validates number-ness before submitting', () => {
@@ -105,7 +105,7 @@ describe('Slider Prompt Container', () => {
105105
const componentProps = wrapper.find(SliderPromptComponent).props();
106106
componentProps.onChangeMin({target: {value: 'hello'}});
107107
componentProps.onOk();
108-
expect(onOk).not.toBeCalled();
109-
expect(onCancel).toBeCalled();
108+
expect(onOk).not.toHaveBeenCalled();
109+
expect(onCancel).toHaveBeenCalled();
110110
});
111111
});

test/unit/util/drag-recognizer.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@ describe('DragRecognizer', () => {
1818
test('start -> small drag', () => {
1919
dragRecognizer.start({clientX: 100, clientY: 100});
2020
window.dispatchEvent(new MouseEvent('mousemove', {clientX: 101, clientY: 101}));
21-
expect(onDrag).not.toBeCalled();
21+
expect(onDrag).not.toHaveBeenCalled();
2222
});
2323

2424
test('start -> large vertical touch move -> scroll, not drag', () => {
2525
dragRecognizer.start({clientX: 100, clientY: 100});
2626
window.dispatchEvent(new MouseEvent('touchmove', {clientX: 106, clientY: 150}));
27-
expect(onDrag).not.toBeCalled();
27+
expect(onDrag).not.toHaveBeenCalled();
2828
});
2929

3030
test('start -> large vertical mouse move -> mouse moves always drag)', () => {
3131
dragRecognizer.start({clientX: 100, clientY: 100});
3232
window.dispatchEvent(new MouseEvent('mousemove', {clientX: 100, clientY: 150}));
33-
expect(onDrag).toBeCalled();
33+
expect(onDrag).toHaveBeenCalled();
3434
});
3535

3636
test('start -> large horizontal touch move -> drag', () => {
3737
dragRecognizer.start({clientX: 100, clientY: 100});
3838
window.dispatchEvent(new MouseEvent('touchmove', {clientX: 150, clientY: 106}));
39-
expect(onDrag).toBeCalled();
39+
expect(onDrag).toHaveBeenCalled();
4040
});
4141

4242
test('after starting a scroll, it cannot become a drag', () => {
4343
dragRecognizer.start({clientX: 100, clientY: 100});
4444
window.dispatchEvent(new MouseEvent('touchmove', {clientX: 100, clientY: 110}));
4545
window.dispatchEvent(new MouseEvent('touchmove', {clientX: 100, clientY: 100}));
4646
window.dispatchEvent(new MouseEvent('touchmove', {clientX: 110, clientY: 100}));
47-
expect(onDrag).not.toBeCalled();
47+
expect(onDrag).not.toHaveBeenCalled();
4848
});
4949

5050
test('start -> end unbinds', () => {

test/unit/util/project-saver-hoc.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ describe('projectSaverHOC', () => {
423423
expect(mockedOnRemixing).toHaveBeenCalledWith(true);
424424
});
425425

426-
test('when starting to remix, onRemixing should be called with param true', () => {
426+
test('when starting to remix, onRemixing should be called with param false', () => {
427427
const mockedOnRemixing = jest.fn();
428428
const mockedStoreProject = jest.fn(() => Promise.resolve());
429429
const Component = () => <div />;

0 commit comments

Comments
 (0)