├── .gitignore
├── README.md
├── package.json
├── public
├── favicon.ico
├── index.html
└── manifest.json
├── src
├── App.css
├── App.js
├── __tests__
│ ├── App.spec.js
│ ├── Button.spec.js
│ ├── Display.spec.js
│ └── Panel.spec.js
├── components
│ ├── Button
│ │ ├── Button.css
│ │ └── Button.js
│ ├── Display
│ │ ├── Display.css
│ │ └── Display.js
│ └── Panel
│ │ ├── Panel.css
│ │ └── Panel.js
├── index.css
├── index.js
├── logic
│ ├── calculate.js
│ └── operate.js
└── setupTests.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | /node_modules
5 |
6 | # testing
7 | /coverage
8 |
9 | # production
10 | /build
11 |
12 | # editor
13 | .vscode
14 |
15 | # misc
16 | .DS_Store
17 | .env.local
18 | .env.development.local
19 | .env.test.local
20 | .env.production.local
21 |
22 | npm-debug.log*
23 | yarn-debug.log*
24 | yarn-error.log*
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # React Testing
2 |
3 | This module builds upon the topic of client-side testing by extending it into the realm of React.
4 |
5 | ## Project Description
6 |
7 | The objectives of this module are the following:
8 |
9 | - To write tests for a React application using Jest and Enzyme. These two libraries are commonly used in production for testing React components and applications.
10 | - To practice reading over and understanding code which you did not write, but that you do need to test.
11 |
12 | For this exercise, you're given a complete React application. Your job is to:
13 |
14 | 1. Go through and inspect **_all_** of the different pieces of the code.
15 | 2. Write tests for **_all_** of the components in the `./src/components` directory.
16 | 3. Write these tests in the correspondingly-named files in the `./src/__tests__` directory.
17 |
18 | You'll be using [Jest](https://facebook.github.io/jest/docs/en/expect.html) and [Enzyme](http://airbnb.io/enzyme/) in order to test React components.
19 |
20 | ## Initialization and Setup
21 |
22 | You can run the complete application by installing Node modules with the `yarn` command, and then running `yarn start`.
23 |
24 | Run `yarn test` in order to run the test suite. Of course, this isn't going to actually test anything yet, since you haven't written the tests!
25 |
26 | ## Stretch Goals
27 |
28 | Add additional test files `calculate.test.js` and `operate.test.js` in the `tests` directory to test the files in the `./src/logic` folder. The files in this directory aren't React components, so for testing them you'll actually just be using Jest without Enzyme.
29 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "calculator",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "react": "^16.6.3",
7 | "react-dom": "^16.6.3",
8 | "react-scripts": "^2.1.1"
9 | },
10 | "scripts": {
11 | "start": "react-scripts start",
12 | "build": "react-scripts build",
13 | "test": "react-scripts test --env=jsdom",
14 | "eject": "react-scripts eject"
15 | },
16 | "devDependencies": {
17 | "enzyme": "^3.7.0",
18 | "enzyme-adapter-react-16": "^1.7.0"
19 | },
20 | "browserslist": [
21 | ">0.2%",
22 | "not dead",
23 | "not ie <= 11",
24 | "not op_mini all"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bloominstituteoftechnology/React-Testing/c4ba830ee962279228e0622035aac81e08a0c366/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |