Skip to content

Commit ad1c0c4

Browse files
committed
Revert "Merge branch 'jest'"
This reverts commit f76e9e1.
1 parent f76e9e1 commit ad1c0c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+216
-6165
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

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

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
.vscode
2-
node_modules/
3-
.DS_Store
1+
.vscode

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ Before you start you should have a few things installed on your machine:
1414

1515
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.
1616

17-
**Note**: Due to the way Jest handles failed tests, it may 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.
18-
1917
The first exercise, `helloWorld`, will walk you through the process in-depth.
2018

2119
## Solutions

caesar/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Exercise 13 - Caesar cipher
1+
# Exercise XX - caesar cipher
22

3-
Implement the legendary Caesar cipher:
3+
Implement the legendary caesar cipher:
44

55
> In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.
66
@@ -31,3 +31,5 @@ negative numbers should work as well:
3131
```javascript
3232
caesar('Mjqqt, Btwqi!', -5) // returns 'Hello, World!'
3333
```
34+
35+

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

calculator/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Exercise 08 - Calculator
2-
31
The goal for this exercise is to create a calculator that does the following:
42

53
add, subtract, get the sum, multiply, get the power, and find the factorial
64

7-
In order to do this please fill out each function with your solution. Make sure to return the value so you can test it in Jest! To see the expected value
8-
take a look at the spec file that houses the Jest test cases.
5+
In order to do this please fill out each function with your solution. Make sure to return the value so you can test it in Jasmine! To see the expected value
6+
take a look at the spec file that houses the Jasmine test cases.

calculator/calculator.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
const add = function() {
1+
function add () {
22

3-
};
3+
}
44

5-
const subtract = function() {
5+
function subtract () {
66

7-
};
7+
}
88

9-
const sum = function() {
9+
function sum () {
1010

11-
};
12-
13-
const multiply = function() {
11+
}
1412

15-
};;
13+
function multiply () {
14+
15+
}
1616

17-
const power = function() {
17+
function power() {
1818

19-
};
19+
}
2020

21-
const factorial = function() {
21+
function factorial() {
2222

23-
};
23+
}
2424

2525
module.exports = {
2626
add,
2727
subtract,
2828
sum,
2929
multiply,
3030
power,
31-
factorial
31+
factorial,
3232
};

calculator/calculator.spec.js

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

33
describe('add', function() {
44
it('adds 0 and 0', function() {
55
expect(calculator.add(0,0)).toEqual(0);
66
});
77

8-
test.skip('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.skip('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.skip('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.skip('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.skip('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.skip('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.skip('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.skip('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.skip('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.skip('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

fibonacci/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Exercise 10 - Fibonacci
1+
# Exercise XX - fibonacci
22

3-
Create a function that returns a specific member of the Fibonacci sequence:
3+
Create a function that returns a specific member of the fibonacci sequence:
44

5-
> A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
5+
> a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
66
77
```javascript
88
fibonacci(4) // returns the 4th member of the series: 3 (1, 1, 2, 3)

fibonacci/fibonacci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const fibonacci = function () {};
22

3-
};
3+
module.exports = fibonacci

findTheOldest/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# Exercise 12 - Find the Oldest
1+
# Find the Oldest
22

3-
Given an array of objects representing people with a birth and death year, return the oldest person.
3+
given an array of objects representing people with a birth and death year, return the oldest person.
44

55
## Hints
66
- You should return the whole person object, but the tests mostly just check to make sure the name is correct.
77
- this can be done with a couple of chained array methods, or by using `reduce`.
88
- One of the tests checks for people with no death-date.. use JavaScript's Date function to get their age as of today.
9+

findTheOldest/findTheOldest.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const findTheOldest = function() {
2-
3-
};
4-
1+
let findTheOldest = function() {
2+
}
53
module.exports = findTheOldest;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
let <%= title %> = function() {
22

3-
};
3+
}
44

5-
module.exports = <%= title %>;
5+
module.exports = <%= title %>

generator-exercise/generators/app/templates/title.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let <%= title %> = require('./<%=title%>')
22

33
describe('<%=title%>', function() {
4-
test('EDITME', function() {
4+
it('EDITME', function() {
55
expect(<%=title%>()).toEqual(' ');
66
});
77

getTheTitles/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Exercise 11 - Get the Titles!
1+
# Get the Titles!
22

33
You are given an array of objects that represent books with an author and a title that looks like this:
44

@@ -15,7 +15,7 @@ const books = [
1515
]
1616
```
1717

18-
Your job is to write a function that takes the array and returns an array of titles:
18+
your job is to write a function that takes the array and returns an array of titles:
1919

2020
```javascript
2121
getTheTitles(books) // ['Book','Book2']

getTheTitles/getTheTitles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const getTheTitles = function() {
22

3-
};
3+
}
44

55
module.exports = getTheTitles;

getTheTitles/getTheTitles.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('getTheTitles', function() {
1212
}
1313
]
1414

15-
test('gets titles', () => {
15+
it('gets titles', function() {
1616
expect(getTheTitles(books)).toEqual(['Book','Book2']);
1717
});
1818
});

helloWorld/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Exercise 01 - Hello World
1+
# Exercise 01 - Hello World.
22

33
The main purpose of this exercise is to walk you through the process of running the tests and make sure everything is set up and running correctly.
44

@@ -13,16 +13,16 @@ Let's look at the spec file first:
1313
const helloWorld = require('./helloWorld');
1414

1515
describe('Hello World', function() {
16-
test('says hello world', function() {
16+
it('says hello world', function() {
1717
expect(helloWorld()).toEqual('Hello, World!');
1818
});
1919
});
2020
```
2121
At the very top of the file we use `require()` to import the code from the javascript file (`helloWorld.js`) so that we can test it.
2222

23-
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `test()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
23+
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `it()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
2424

25-
For now you do not need to worry about how to write tests, but you should try to get comfortable enough with the syntax to figure out what the tests are asking you to do. Go ahead and run the tests by entering `npm test helloWorld.spec.js` in the terminal and watch it fail. The output from that command should tell you exactly what went wrong with your code. In this case, running the `helloWorld()` function should return the phrase 'Hello, World!' but instead it returns an empty string...
25+
For now you do not need to worry about how to write tests, but you should try to get comfortable enough with the syntax to figure out what the tests are asking you to do. Go ahead and run the tests by entering `jasmine helloWorld.spec.js` in the terminal and watch it fail. The output from that command should tell you exactly what went wrong with your code. In this case, running the `helloWorld()` function should return the phrase 'Hello, World!' but instead it returns an empty string...
2626

2727
so let's look at the javascript file:
2828
```javascript

leapYears/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Exercise 06 - leapYears
1+
# Exercise XX - leapYears
22

33
Create a function that determines whether or not a given year is a leap year. Leap years are determined by the following rules:
44

leapYears/leapYears.js

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

3-
};
3+
}
44

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

0 commit comments

Comments
 (0)