8000 Merge pull request #145 from TheOdinProject/fix/revert-jest · jinc1026/javascript-exercises@ac73d92 · GitHub
[go: up one dir, main page]

Skip to content

Commit ac73d92

Browse files
authored
Merge pull request TheOdinProject#145 from TheOdinProject/fix/revert-jest
Fix/revert jest
2 parents 2fb5731 + 8272bde commit ac73d92

39 files changed

+5992
-269
lines changed

.eslintrc.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
.vscode
2-
node_modules/
3-
package-lock.json
4-
package.json
5-
.eslintrc
6-
.DS_Store
1+
.vscode

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ There will eventually be a suggested order of completion, but at this time since
99
## How To Use These Exercises
1010
Before you start you should have a few things installed on your machine:
1111
1. NPM. To check if you have NPM installed, type `npm --version` in your terminal. If you get back `Command 'npm' not found, but can be installed with:`, do NOT follow the instructions in the terminal to install with `apt-get`. (This causes permission issues.) Instead, install Node with NVM by following the instructions [here](https://github.com/TheOdinProject/curriculum/blob/master/foundations/installations/installing_node.md).
12-
2. Jest. Jest is a testing framework for JavaScript. To install it, type `npm install --save-dev jest`. We use `--save-dev` here to specify this module is for development purposes only.
13-
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
12+
2. Jasmine. Jasmine is a testing framework for JavaScript. Type `jasmine -v` to check for it. If you need to install it, type `npm install -g jasmine` to do so.
13+
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/duplicating-a-repository)
1414

15-
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `npm test exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'test.skip' compared to 'test'. This is purposeful. After you pass your first 'test', you will change the next 'test.skip' to an 'test' and test your code again. You'll do this until all conditions are satisfied.
16-
17-
**Note**: Due to the way Jest handles failed tests, it will return an exit code of 1 if any tests fail. NPM will interpret this as an error and you may see some `npm ERR!` messages after Jest runs. You can ignore these, or run your test with `npm test exerciseName.spec.js --silent` to supress the errors.
15+
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `jasmine exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'xit' compared to 'it'. This is purposeful. After you pass your first 'it', you will change the next 'xit' to an 'it' and test your code again. You'll do this until all conditions are satisfied.
1816

1917
The first exercise, `helloWorld`, will walk you through the process in-depth.
2018

caesar/.DS_Store

6 KB
Binary file not shown.

caesar/caesar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const caesar = function() {
22

3-
};
3+
}
44

5-
module.exports = caesar;
5+
module.exports = caesar

caesar/caesar.spec.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
const caesar = require("./caesar");
1+
const caesar = require('./caesar')
22

3-
test('works with single letters', () => {
4-
expect(caesar('A', 1)).toBe('B');
5-
});
6-
test.skip('works with words', () => {
7-
expect(caesar('Aaa', 1)).toBe('Bbb');
8-
});
9-
test.skip('works with phrases', () => {
10-
expect(caesar('Hello, World!', 5)).toBe('Mjqqt, Btwqi!');
11-
});
12-
test.skip('works with negative shift', () => {
13-
expect(caesar('Mjqqt, Btwqi!', -5)).toBe('Hello, World!');
14-
});
15-
test.skip('wraps', () => {
16-
expect(caesar('Z', 1)).toBe('A');
17-
});
18-
test.skip('works with large shift factors', () => {
19-
expect(caesar('Hello, World!', 75)).toBe('Ebiil, Tloia!');
20-
});
21-
test.skip('works with large negative shift factors', () => {
22-
expect(caesar('Hello, World!', -29)).toBe('Ebiil, Tloia!');
3+
describe('caesar', function() {
4+
it('works with single letters', function() {
5+
expect(caesar('A', 1)).toEqual('B');
6+
});
7+
xit('works with words', function() {
8+
expect(caesar('Aaa', 1)).toEqual('Bbb');
9+
});
10+
xit('works with phrases', function() {
11+
expect(caesar('Hello, World!', 5)).toEqual('Mjqqt, Btwqi!');
12+
});
13+
xit('works with negative shift', function() {
14+
expect(caesar('Mjqqt, Btwqi!', -5)).toEqual('Hello, World!');
15+
});
16+
xit('wraps', function() {
17+
expect(caesar('Z', 1)).toEqual('A');
18+
});
19+
xit('works with large shift factors', function() {
20+
expect(caesar('Hello, World!', 75)).toEqual('Ebiil, Tloia!');
21+
});
22+
xit('works with large negative shift factors', function() {
23+
expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!');
24+
});
2325
});

calculator/calculator.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
const add = function() {
2-
1+
function add () {
2+
33
}
44

5-
const subtract = function() {
6-
5+
function subtract () {
6+
77
}
88

9-
const sum = function() {
10-
9+
function sum () {
10+
1111
}
1212

13-
const multiply = function() {
14-
13+
function multiply () {
14+
1515
}
1616

17-
const power = function() {
18-
17+
function power() {
18+
1919
}
2020

21-
const factorial = function() {
22-
21+
function factorial() {
22+
2323
}
2424

2525
module.exports = {
@@ -28,5 +28,5 @@ module.exports = {
2828
sum,
2929
multiply,
3030
power,
31-
factorial
31+
factorial,
3232
};

calculator/calculator.spec.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,77 @@
11
const calculator = require ('./calculator.js');
22

3-
describe('add', () => {
4-
test('adds 0 and 0', () => {
5-
expect(calculator.add(0,0)).toBe(0);
3+
describe('add', function() {
4+
it('adds 0 and 0', function() {
5+
expect(calculator.add(0,0)).toEqual(0);
66
});
77

8-
test('adds 2 and 2', () => {
9-
expect(calculator.add(2,2)).toBe(4);
8+
xit('adds 2 and 2', function() {
9+
expect(calculator.add(2,2)).toEqual(4);
1010
});
1111

12-
test('adds positive numbers', () => {
13-
expect(calculator.add(2,6)).toBe(8);
12+
xit('adds positive numbers', function() {
13+
expect(calculator.add(2,6)).toEqual(8);
1414
});
1515
});
1616

17-
describe('subtract', () => {
18-
test('subtracts numbers', () => {
19-
expect(calculator.subtract(10,4)).toBe(6);
17+
describe('subtract', function() {
18+
xit('subtracts numbers', function() {
19+
expect(calculator.subtract(10,4)).toEqual(6);
2020
});
2121
});
2222

23-
describe('sum', () => {
24-
test('computes the sum of an empty array', () => {
25-
expect(calculator.sum([])).toBe(0);
23+
describe('sum', function() {
24+
xit('computes the sum of an empty array', function() {
25+
expect(calculator.sum([])).toEqual(0);
2626
});
2727

28-
test('computes the sum of an array of one number', () => {
29-
expect(calculator.sum([7])).toBe(7);
28+
xit('computes the sum of an array of one number', function() {
29+
expect(calculator.sum([7])).toEqual(7);
3030
});
3131

32-
test('computes the sum of an array of two numbers', () => {
33-
expect(calculator.sum([7,11])).toBe(18);
32+
xit('computes the sum of an array of two numbers', function() {
33+
expect(calculator.sum([7,11])).toEqual(18);
3434
});
3535

36-
test('computes the sum of an array of many numbers', () => {
37-
expect(calculator.sum([1,3,5,7,9])).toBe(25);
36+
xit('computes the sum of an array of many numbers', function() {
37+
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
3838
});
3939
});
4040

41-
describe('multiply', () => {
42-
test('multiplies two numbers', () => {
43-
expect(calculator.multiply([2,4])).toBe(8);
41+
describe('multiply', function() {
42+
xit('multiplies two numbers', function() {
43+
expect(calculator.multiply([2,4])).toEqual(8);
4444
});
4545

46-
test('multiplies several numbers', () => {
47-
expect(calculator.multiply([2,4,6,8,10,12,14])).toBe(645120);
46+
xit('multiplies several numbers', function() {
47+
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
4848
});
4949
});
5050

51-
describe('power', () => {
52-
test('raises one number to the power of another number', () => {
53-
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
51+
describe('power', function() {
52+
xit('raises one number to the power of another number', function() {
53+
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
5454
});
5555
});
5656

57-
describe('factorial', () => {
58-
test.skip('computes the factorial of 0', () => {
59-
expect(calculator.factorial(0)).toBe(1); // 0! = 1
57 10000 +
describe('factorial', function() {
58+
xit('computes the factorial of 0', function() {
59+
expect(calculator.factorial(0)).toEqual(1); // 0! = 1
6060
});
6161

62-
test.skip('computes the factorial of 1', () => {
63-
expect(calculator.factorial(1)).toBe(1);
62+
xit('computes the factorial of 1', function() {
63+
expect(calculator.factorial(1)).toEqual(1);
6464
});
6565

66-
test.skip('computes the factorial of 2', () => {
67-
expect(calculator.factorial(2)).toBe(2);
66+
xit('computes the factorial of 2', function() {
67+
expect(calculator.factorial(2)).toEqual(2);
6868
});
6969

70-
test.skip('computes the factorial of 5', () => {
71-
expect(calculator.factorial(5)).toBe(120);
70+
xit('computes the factorial of 5', function() {
71+
expect(calculator.factorial(5)).toEqual(120);
7272
});
7373

74-
test.skip('computes the factorial of 10', () => {
75-
expect(calculator.factorial(10)).toBe(3628800);
74+
xit('computes the factorial of 10', function() {
75+
expect(calculator.factorial(10)).toEqual(3628800);
7676
});
7777
});

fibonacci/fibonacci.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const fibonacci = function() {
1+
const fibonacci = function () {};
22

3-
}
4-
5-
module.exports = fibonacci;
3+
module.exports = fibonacci

fibonacci/fibonacci.spec.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
const fibonacci = require("./fibonacci");
1+
const fibonacci = require('./fibonacci')
22

3-
describe('fibonacci', () => {
4-
test('4th fibonacci number is 3', () => {
5-
expect(fibonacci(4)).toBe(3);
3+
describe('fibonacci', function() {
4+
it('works', function() {
5+
expect(fibonacci(4)).toEqual(3);
66
});
7-
test.skip('6th fibonacci number is 8', () => {
8-
expect(fibonacci(6)).toBe(8);
7+
xit('works', function() {
8+
expect(fibonacci(6)).toEqual(8);
99
});
10-
test.skip('10th fibonacci number is 55', () => {
11-
expect(fibonacci(10)).toBe(55);
10+
xit('works', function() {
11+
expect(fibonacci(10)).toEqual(55);
1212
});
13-
test.skip('15th fibonacci number is 610', () => {
14-
expect(fibonacci(15)).toBe(610);
13+
xit('works', function() {
14+
expect(fibonacci(15)).toEqual(610);
1515
});
16-
test.skip('25th fibonacci number is 75025', () => {
17-
expect(fibonacci(25)).toBe(75025);
16+
xit('works', function() {
17+
expect(fibonacci(25)).toEqual(75025);
1818
});
19-
test.skip('doesn\'t accept negatives', () => {
20-
expect(fibonacci(-25)).toBe("OOPS");
19+
xit('doesn\'t accept negatives', function() {
20+
expect(fibonacci(-25)).toEqual("OOPS");
2121
});
22-
test.skip('DOES accept strings', () => {
23-
expect(fibonacci("1")).toBe(1);
22+
xit('DOES accept strings', function() {
23+
expect(fibonacci("1")).toEqual(1);
2424
});
25-
test.skip('DOES accept strings', () => {
26-
expect(fibonacci("2")).toBe(1);
25+
xit('DOES accept strings', function() {
26+
expect(fibonacci("2")).toEqual(1);
2727
});
28-
test.skip('DOES accept strings', () => {
29-
expect(fibonacci("8")).toBe(21);
28+
xit('DOES accept strings', function() {
29+
expect(fibonacci("8")).toEqual(21);
3030
});
3131
});

0 commit comments

Comments
 (0)
0