Skip to content

Commit b26f3c7

Browse files
authored
Merge pull request #1060 from rvsia/addJestPluginForEslint
Add jest plugin for eslint
2 parents 7f7ad99 + fe2b4a3 commit b26f3c7

File tree

7 files changed

+65
-47
lines changed

7 files changed

+65
-47
lines changed

.eslintrc.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"it": true,
2222
"arguments": true
2323
},
24-
"plugins": ["react"],
24+
"plugins": ["react", "jest"],
2525
"extends": ["react-app", "eslint:recommended", "plugin:react/recommended", "plugin:prettier/recommended", "prettier"],
2626
"env": {
2727
"es6": true,
@@ -85,6 +85,8 @@
8585
"no-mixed-operators": "error",
8686
"no-unused-expressions": "error",
8787
"no-sequences": "error",
88-
"react-hooks/exhaustive-deps": 0
88+
"react-hooks/exhaustive-deps": 0,
89+
"jest/no-focused-tests": "error",
90+
"jest/no-identical-title": "error"
8991
}
9092
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"eslint-loader": "^4.0.2",
7575
"eslint-plugin-flowtype": "^5.3.1",
7676
"eslint-plugin-import": "^2.22.1",
77+
"eslint-plugin-jest": "^24.3.6",
7778
"eslint-plugin-jsx-a11y": "^6.4.1",
7879
"eslint-plugin-prettier": "^3.3.1",
7980
"eslint-plugin-react": "^7.22.0",

packages/blueprint-component-mapper/src/tests/components.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('formFields generated tests', () => {
266266
}
267267
});
268268

269-
it('renders with error', () => {
269+
it('renders with submit error', () => {
270270
const wrapper = mount(<RendererWrapper schema={schema} onSubmit={() => ({ [field.name]: errorText })} />);
271271
wrapper.find('form').simulate('submit');
272272
expect(

packages/pf4-component-mapper/src/tests/wizard/wizard.test.js

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,44 +1360,6 @@ describe('<Wizard />', () => {
13601360
).toEqual(true);
13611361
});
13621362

1363-
it('disable nav when jumped into compileMapper step', () => {
1364-
const wrapper = mount(
1365-
<FormRenderer
1366-
schema={wizardSchema}
1367-
componentMapper={componentMapper}
1368-
FormTemplate={(props) => <FormTemplate {...props} showFormControls={false} />}
1369-
onSubmit={jest.fn()}
1370-
onCancel={jest.fn()}
1371-
/>
1372-
);
1373-
1374-
changeValue(wrapper, 'aws');
1375-
nextButtonClick(wrapper);
1376-
1377-
expect(wrapper.find(WizardNavItem)).toHaveLength(3);
1378-
1379-
backButtonClick(wrapper);
1380-
1381-
expect(
1382-
wrapper
1383-
.find(WizardNavItem)
1384-
.at(0)
1385-
.props().isDisabled
1386-
).toEqual(false);
1387-
expect(
1388-
wrapper
1389-
.find(WizardNavItem)
1390-
.at(1)
1391-
.props().isDisabled
1392-
).toEqual(true);
1393-
expect(
1394-
wrapper
1395-
.find(WizardNavItem)
1396-
.at(2)
1397-
.props().isDisabled
1398-
).toEqual(true);
1399-
});
1400-
14011363
it('disable nav when jumped into compileMapper step from invalid step', () => {
14021364
const wizardSchema = {
14031365
fields: [
@@ -1908,7 +1870,7 @@ describe('<Wizard />', () => {
19081870
expect(reducer(initialState, { type: 'closeNav' })).toEqual({ openNav: false });
19091871
});
19101872

1911-
it('returns default', () => {
1873+
it('opens nav', () => {
19121874
const initialState = { openNav: false };
19131875
expect(reducer(initialState, { type: 'openNav' })).toEqual({ openNav: true });
19141876
});

packages/react-form-renderer/src/tests/form-renderer/parse-condition.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ describe('parseCondition', () => {
224224
expect(parseCondition(condition, values)).toEqual(positiveResult);
225225
});
226226

227-
it('nested test 1 - true', () => {
227+
it('nested test 2 - true', () => {
228228
condition = {
229229
or: [{ not: { when: 'x', pattern: /true/ } }, { not: { when: 'y', pattern: /true/ } }, { not: { when: 'z', pattern: /true/ } }]
230230
};
@@ -252,7 +252,7 @@ describe('parseCondition', () => {
252252
expect(parseCondition(condition, values)).toEqual(negativeResult);
253253
});
254254

255-
it('nested test 2 - true', () => {
255+
it('nested test 3 - true', () => {
256256
condition = {
257257
and: [
258258
{
@@ -280,7 +280,7 @@ describe('parseCondition', () => {
280280
expect(parseCondition(condition, values)).toEqual(positiveResult);
281281
});
282282

283-
it('nested test 2 - true', () => {
283+
it('nested test 4 - true', () => {
284284
condition = {
285285
and: [
286286
{

packages/react-form-renderer/src/tests/validators/validators.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('New validators', () => {
7676
expect(validatorMapper[validatorTypes.MIN_ITEMS]({ threshold: 3 })(['1', '2', '3'])).toBeUndefined();
7777
});
7878

79-
it('should pass min items of 3 validation', () => {
79+
it('should pass min items of 3 validation with message', () => {
8080
expect(validatorMapper[validatorTypes.MIN_ITEMS]({ threshold: 3, message: 'Too few' })(['1', '2'])).toBe('Too few');
8181
});
8282

@@ -271,7 +271,7 @@ describe('New validators', () => {
271271
expect(dataTypeValidator('integer')()([1, 2, 3])).toBeUndefined();
272272
});
273273

274-
it('should fail validation of an array of strings', () => {
274+
it('should fail validation of an array of strings to integer', () => {
275275
expect(dataTypeValidator('integer')()([1, 2, 2.1])).toBe('Value must be integer');
276276
expect(dataTypeValidator('integer')()([1, 2, 'foo'])).toBe('Value must be integer');
277277
});

yarn.lock

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,31 @@
40344034
eslint-scope "^5.0.0"
40354035
eslint-utils "^2.0.0"
40364036

4037+
"@typescript-eslint/experimental-utils@^4.0.1":
4038+
version "4.25.0"
4039+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.25.0.tgz#b2febcfa715d2c1806fd5f0335193a6cd270df54"
4040+
integrity sha512-f0doRE76vq7NEEU0tw+ajv6CrmPelw5wLoaghEHkA2dNLFb3T/zJQqGPQ0OYt5XlZaS13MtnN+GTPCuUVg338w==
4041+
dependencies:
4042+
"@types/json-schema" "^7.0.3"
4043+
"@typescript-eslint/scope-manager" "4.25.0"
4044+
"@typescript-eslint/types" "4.25.0"
4045+
"@typescript-eslint/typescript-estree" "4.25.0"
4046+
eslint-scope "^5.0.0"
4047+
eslint-utils "^2.0.0"
4048+
4049+
"@typescript-eslint/[email protected]":
4050+
version "4.25.0"
4051+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.25.0.tgz#9d86a5bcc46ef40acd03d85ad4e908e5aab8d4ca"
4052+
integrity sha512-2NElKxMb/0rya+NJG1U71BuNnp1TBd1JgzYsldsdA83h/20Tvnf/HrwhiSlNmuq6Vqa0EzidsvkTArwoq+tH6w==
4053+
dependencies:
4054+
"@typescript-eslint/types" "4.25.0"
4055+
"@typescript-eslint/visitor-keys" "4.25.0"
4056+
4057+
"@typescript-eslint/[email protected]":
4058+
version "4.25.0"
4059+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.25.0.tgz#0e444a5c5e3c22d7ffa5e16e0e60510b3de5af87"
4060+
integrity sha512-+CNINNvl00OkW6wEsi32wU5MhHti2J25TJsJJqgQmJu3B3dYDBcmOxcE5w9cgoM13TrdE/5ND2HoEnBohasxRQ==
4061+
40374062
"@typescript-eslint/[email protected]":
40384063
version "3.0.0"
40394064
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.0.tgz#fa40e1b76ccff880130be054d9c398e96004bf42"
@@ -4047,6 +4072,27 @@
40474072
semver "^7.3.2"
40484073
tsutils "^3.17.1"
40494074

4075+
"@typescript-eslint/[email protected]":
4076+
version "4.25.0"
4077+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.25.0.tgz#942e4e25888736bff5b360d9b0b61e013d0cfa25"
4078+
integrity sha512-1B8U07TGNAFMxZbSpF6jqiDs1cVGO0izVkf18Q/SPcUAc9LhHxzvSowXDTvkHMWUVuPpagupaW63gB6ahTXVlg==
4079+
dependencies:
4080+
"@typescript-eslint/types" "4.25.0"
4081+
"@typescript-eslint/visitor-keys" "4.25.0"
4082+
debug "^4.1.1"
4083+
globby "^11.0.1"
4084+
is-glob "^4.0.1"
4085+
semver "^7.3.2"
4086+
tsutils "^3.17.1"
4087+
4088+
"@typescript-eslint/[email protected]":
4089+
version "4.25.0"
4090+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.25.0.tgz#863e7ed23da4287c5b469b13223255d0fde6aaa7"
4091+
integrity sha512-AmkqV9dDJVKP/TcZrbf6s6i1zYXt5Hl8qOLrRDTFfRNae4+LB8A4N3i+FLZPW85zIxRy39BgeWOfMS3HoH5ngg==
4092+
dependencies:
4093+
"@typescript-eslint/types" "4.25.0"
4094+
eslint-visitor-keys "^2.0.0"
4095+
40504096
"@webassemblyjs/[email protected]":
40514097
version "1.9.0"
40524098
resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964"
@@ -8455,6 +8501,13 @@ eslint-plugin-import@^2.22.1:
84558501
resolve "^1.17.0"
84568502
tsconfig-paths "^3.9.0"
84578503

8504+
eslint-plugin-jest@^24.3.6:
8505+
version "24.3.6"
8506+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.3.6.tgz#5f0ca019183c3188c5ad3af8e80b41de6c8e9173"
8507+
integrity sha512-WOVH4TIaBLIeCX576rLcOgjNXqP+jNlCiEmRgFTfQtJ52DpwnIQKAVGlGPAN7CZ33bW6eNfHD6s8ZbEUTQubJg==
8508+
dependencies:
8509+
"@typescript-eslint/experimental-utils" "^4.0.1"
8510+
84588511
eslint-plugin-jsx-a11y@^6.4.1:
84598512
version "6.4.1"
84608513
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz#a2d84caa49756942f42f1ffab9002436391718fd"

0 commit comments

Comments
 (0)