Skip to content

Conversation

@lotrien
Copy link
Member

@lotrien lotrien commented Jan 4, 2018

Since we have to provide reliable components there is a need to cover
them with tests. This commit contains tests for Title and Spinner
components.

@lotrien lotrien changed the title Add unit ans basic snapshot tests for two components from common folder Add unit and basic snapshot tests for two components from common folder Jan 4, 2018
Copy link
Member

@ikalnytskyi ikalnytskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks almost good to me except for irrelevant package-lock.json changes. Could you please remove them? Also, see other comments inline.

"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.4.0",
"extract-text-webpack-plugin": "^3.0.2",
"fetch-mock": "^6.0.0-beta.2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant

testSetup.js Outdated
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add few lines that explains what is it and why we need it.

"./testSetup.js"
],
"moduleNameMapper": {
"^.+\\.(css|styl|svg)$": "identity-obj-proxy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack is crap :(

package.json Outdated
],
"jest": {
"setupFiles": [
"./testSetup.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. why start with dot? Why not tests/testSetup.js?

Copy link
Member Author

@lotrien lotrien Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm why not, about to move to test folder and fix this line.But anyway with changed directory path without dot won't work

"version": "8.0.2",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-8.0.2.tgz",
"integrity": "sha1-YpmpBVsc78lp/355wdkY3Osiw2A=",
"version": "10.0.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are a lot of irrelevant changes in package-lock.json. could you please remove them?

@lotrien lotrien force-pushed the tests-for-common branch 2 times, most recently from 8c3a0d4 to 0f9d443 Compare January 4, 2018 14:23
Copy link
Member

@ikalnytskyi ikalnytskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One iteration and we are good :D

package.json Outdated
},
"dependencies": {
"codemirror": "^5.33.0",
"enzyme": "^3.3.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe enzyme should be in devDependencies, shouldn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As well as enzyme-adapter-react-16.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think so, but our linter doesn't

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No way. Just tried to move it under devDependencies - everything works fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange things happened


// To make enzyme work we need to configure Adapter. According
// to the doc this Adapter have additional peer dependencies,
// in our case these dependencies are react, react-dom and react-test-renderer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's much sense in mentioning of peer dependencies – they may change in future while this comment will be here. :P

Also, I'd somehow rewrite it to say:

// Enzyme is React version agnostic and can work with any version through
// adapters system. Enzyme Adapter is a sort of engine that knows how to
// manipulate underlying UI library (it can be used not only with React).
// Since we use React 16, we need to set a proper adapter.

@@ -0,0 +1,11 @@
import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please move component tests into tests/components/Spinner.test.jsx ? I mean ,let's try to follow file structure we have in src/ in order to make it easier to navigate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

Since we have to provide reliable components there is a need to cover
them with tests. This commit contains tests for Title and Spinner
components.
@ikalnytskyi ikalnytskyi merged commit 7a8905c into master Jan 4, 2018
@ikalnytskyi ikalnytskyi deleted the tests-for-common branch January 4, 2018 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants