Skip to content

Commit fe86d27

Browse files
Ryan PedersenRyan Pedersen
authored andcommitted
first commit
1 parent 9252e03 commit fe86d27

File tree

11 files changed

+155
-3
lines changed

11 files changed

+155
-3
lines changed

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: 2.1
2+
3+
orbs:
4+
node: circleci/node@3.0.1
5+
6+
jobs:
7+
build_and_test:
8+
docker:
9+
- image: cimg/node:12.16
10+
parallelism: 5
11+
steps:
12+
- checkout
13+
- node/install-yarn:
14+
pkg-manager: yarn
15+
- run: mkdir ~/junit
16+
- run:
17+
name: Test application
18+
command: |
19+
TEST=$(circleci tests glob /**/__tests__/*.js | circleci tests split --split-by=timings)
20+
yarn test $TEST
21+
- run:
22+
command: cp junit.xml ~/junit/
23+
when: always
24+
- store_test_results:
25+
path: ~/junit
26+
- store_artifacts:
27+
path: ~/junit
28+
workflows:
29+
build-and-test:
30+
jobs:
31+
- build-and-test

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "react-test-splitting",
2+
"name": "circleci-react-test-splitting",
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
@@ -30,5 +30,8 @@
3030
"last 1 firefox version",
3131
"last 1 safari version"
3232
]
33+
},
34+
"devDependencies": {
35+
"jest-junit": "^11.0.1"
3336
}
3437
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render } from '@testing-library/react';
3-
import App from './App';
3+
import App from '../App.js';
44

55
test('renders learn react link', () => {
66
const { getByText } = render(<App />);

src/__tests__/addition.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { add } from '../math';
2+
3+
describe('Addition testing', () => {
4+
test('2 + 2 = 4', () => {
5+
expect(add(2, 2)).toBe(4);
6+
});
7+
8+
test('2 + 3 = 5', () => {
9+
expect(add(2, 3)).toBe(5);
10+
});
11+
12+
test('2 + 5 = 7', () => {
13+
expect(add(2, 5)).toBe(7);
14+
});
15+
16+
test('2 + 7 = 9', () => {
17+
expect(add(2, 7)).toBe(9);
18+
});
19+
20+
test('2 + 20 = 22', () => {
21+
expect(add(2, 20)).toBe(22);
22+
});
23+
})

src/__tests__/division.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { divide } from '../math';
2+
3+
describe('Division testing', () => {
4+
5+
test('8 / 1 = 8', () => {
6+
expect(divide(8, 1)).toBe(8);
7+
});
8+
9+
test('9 / 3 = 2', () => {
10+
expect(divide(9, 3)).toBe(3);
11+
});
12+
})

src/__tests__/filter.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { filterByTerm } from '../filter';
2+
3+
describe("Filter function", () => {
4+
test("it should filter characters by a search term", () => {
5+
const input = [
6+
{ id: 1, name: "Zelda" },
7+
{ id: 2, name: "Ganondorf" },
8+
{ id: 3, name: "Link" }
9+
];
10+
11+
const output = [{ id: 3, name: "Link" }];
12+
13+
expect(filterByTerm(input, "link")).toEqual(output);
14+
15+
expect(filterByTerm(input, "LINK")).toEqual(output);
16+
});
17+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { multiply } from '../math';
2+
3+
describe('Multiplication testing', () => {
4+
test('3 * 3 = 9', () => {
5+
expect(multiply(3, 3)).toBe(9);
6+
});
7+
8+
test('3 * 3 = 9', () => {
9+
expect(multiply(3, 3)).toBe(9);
10+
});
11+
12+
test('3 * 3 = 9', () => {
13+
expect(multiply(3, 5)).toBe(15);
14+
});
15+
16+
})

src/__tests__/subtraction.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { subtract } from '../math';
2+
3+
describe('Subtraction testing', () => {
4+
test('4 - 1 = 3', () => {
5+
expect(subtract(4, 1)).toBe(3);
6+
});
7+
8+
test('4 - 1 = 3', () => {
9+
expect(subtract(4, 1)).toBe(3);
10+
});
11+
12+
test('4 - 1 = 3', () => {
13+
expect(subtract(4, 1)).toBe(3);
14+
});
15+
})

src/filter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const filterByTerm = (inputArr, searchTerm) => {
2+
const regex = new RegExp(searchTerm, "i");
3+
return inputArr.filter((arrayElement) => {
4+
return arrayElement.name.match(regex);
5+
});
6+
7+
}
8+
9+
module.exports = { filterByTerm };

src/math.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const add = (a, b) => a + b;
2+
const multiply = (a, b) => a * b;
3+
const subtract = (a, b) => a - b;
4+
const divide = (a, b) => a / b;
5+
6+
module.exports = { add, multiply, subtract, divide };

0 commit comments

Comments
 (0)