Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9e00b9

Browse files
authored
Merge pull request HackYourFuture#259 from HackYourFuture/post-class19
Post class19
2 parents 4f4219c + 499d757 commit c9e00b9

File tree

11 files changed

+148
-56
lines changed

11 files changed

+148
-56
lines changed

Week1/README.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,42 @@ In week one we will discuss the following topics:
2525
- Live Server
2626
- Bracket Pair Colorizer
2727

28-
2. Install the ESLint tool globally by issuing the following command from the command line:
28+
2. Modify the VSCode User Settings to include the settings listed below. If a particular setting is already present in your User Settings, make sure that the setting value listed below is used and change it if necessary.
29+
30+
To open your user and workspace settings, use the following VS Code menu command:
31+
32+
- On Windows/Linux - **File** > **Preferences** > **Settings**
33+
- On macOS - **Code** > **Preferences** > **Settings**
34+
35+
Then, click on the `{ }` button in the top-right corner of the settings screen to access the settings in JSON format.
36+
37+
```json
38+
/// Place your settings in this file to overwrite the default settings
39+
{
40+
"editor.detectIndentation": false,
41+
"editor.formatOnSave": true,
42+
"editor.formatOnType": true,
43+
"editor.minimap.enabled": false,
44+
"editor.renderIndentGuides": true,
45+
"editor.tabSize": 2,
46+
"files.autoSave": "onFocusChange",
47+
"prettier.printWidth": 100,
48+
"prettier.singleQuote": true,
49+
"prettier.trailingComma": "es5"
50+
}
51+
```
52+
53+
3. Install the ESLint CLI tool globally by issuing the following command from the command line:
2954

3055
```
31-
npm install -g eslint
56+
npm install -g eslint-cli
3257
```
3358

34-
3. Fork this repository (i.e., **JavaScript2**) and clone your fork to your laptop.
59+
4. Fork this repository (i.e., **JavaScript2**) and clone your fork to your laptop.
3560

36-
4. Open the `JavaScript2` folder from the cloned repository in VSCode.
61+
5. Open the `JavaScript2` folder from the cloned repository in VSCode.
3762

38-
5. Open a terminal window in VSCode and type the following command:
63+
6. Open a terminal window in VSCode and type the following command:
3964

4065
```
4166
npm install

Week2/test/maartjes-work.test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const { maartjesTasks, maartjesHourlyRate, computeEarnings } = require(`../homework/maartjes-work`);
22

3-
test('maartjes_work.js', () => {
4-
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
5-
const result = earnings.toFixed(2);
6-
expect(result).toBe('373.33');
3+
describe('maartjes_work', () => {
4+
test('earnings rounded to euro cents', () => {
5+
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
6+
const result = earnings.toFixed(2);
7+
expect(result).toBe('373.33');
8+
});
79
});

Week2/test/map-filter.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const { myNumbers, doubleOddNumbers } = require(`../homework/map-filter`);
22

3-
test('map_filter.js', () => {
4-
const result = doubleOddNumbers(myNumbers);
5-
expect(result).toEqual([2, 6]);
3+
describe('map_filter', () => {
4+
test('result -> [2, 6]', () => {
5+
const result = doubleOddNumbers(myNumbers);
6+
expect(result).toEqual([2, 6]);
7+
});
68
});

Week3/test/step2-1.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ const foo = require('../homework/step2-1');
22

33
const mockFn = jest.fn(() => undefined);
44

5-
test('1-step3.js', () => {
6-
foo(mockFn);
7-
expect(mockFn.mock.calls.length).toBe(1);
5+
describe('step2-1', () => {
6+
test('foo calls func', () => {
7+
foo(mockFn);
8+
expect(mockFn.mock.calls.length).toBe(1);
9+
});
810
});

Week3/test/step2-2.test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ const threeFive = require('../homework/step2-2');
33
const mockSayThree = jest.fn(() => undefined);
44
const mockSayFive = jest.fn(() => undefined);
55

6-
test('2-step3.js', () => {
7-
threeFive(10, 15, mockSayThree, mockSayFive);
6+
describe('step2-2', () => {
7+
test('12 and 15 divisible by 3', () => {
8+
threeFive(10, 15, mockSayThree, () => undefined);
89

9-
expect(mockSayThree.mock.calls.length).toBe(2);
10-
expect(mockSayThree.mock.calls[0][0]).toBe(12);
11-
expect(mockSayThree.mock.calls[1][0]).toBe(15);
10+
expect(mockSayThree.mock.calls.length).toBe(2);
11+
expect(mockSayThree.mock.calls[0][0]).toBe(12);
12+
expect(mockSayThree.mock.calls[1][0]).toBe(15);
13+
});
1214

13-
expect(mockSayFive.mock.calls.length).toBe(2);
14-
expect(mockSayFive.mock.calls[0][0]).toBe(10);
15-
expect(mockSayFive.mock.calls[1][0]).toBe(15);
15+
test('10 and 15 divisible by 5', () => {
16+
threeFive(10, 15, () => undefined, mockSayFive);
17+
18+
expect(mockSayFive.mock.calls.length).toBe(2);
19+
expect(mockSayFive.mock.calls[0][0]).toBe(10);
20+
expect(mockSayFive.mock.calls[1][0]).toBe(15);
21+
});
1622
});

Week3/test/step2-3.test.js

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,68 @@ const {
44
repeatStringNumTimesWithDoWhile
55
} = require('../homework/step2-3');
66

7-
describe('1-step3.js', () => {
8-
test('for-loop', () => {
9-
let result = repeatStringNumTimesWithFor('abc', 3);
7+
describe('step2-3 with for-loop', () => {
8+
test('num = 3', () => {
9+
const result = repeatStringNumTimesWithFor('abc', 3);
1010
expect(result).toBe('abcabcabc');
11+
});
1112

12-
result = repeatStringNumTimesWithFor('abc', 1);
13+
test('num = 1', () => {
14+
const result = repeatStringNumTimesWithFor('abc', 1);
1315
expect(result).toBe('abc');
16+
});
1417

15-
result = repeatStringNumTimesWithFor('abc', -2);
18+
test('num = -2', () => {
19+
const result = repeatStringNumTimesWithFor('abc', -2);
1620
expect(result).toBe('');
1721
});
1822

19-
test('while-loop', () => {
20-
let result = repeatStringNumTimesWithWhile('abc', 3);
23+
test('num = 0', () => {
24+
const result = repeatStringNumTimesWithFor('abc', 0);
25+
expect(result).toBe('');
26+
});
27+
});
28+
29+
describe('step2-3 with while-loop', () => {
30+
test('num = 3', () => {
31+
const result = repeatStringNumTimesWithWhile('abc', 3);
2132
expect(result).toBe('abcabcabc');
33+
});
2234

23-
result = repeatStringNumTimesWithFor('abc', 1);
35+
test('num = 1', () => {
36+
const result = repeatStringNumTimesWithWhile('abc', 1);
2437
expect(result).toBe('abc');
38+
});
2539

26-
result = repeatStringNumTimesWithFor('abc', -2);
40+
test('num = 0', () => {
41+
const result = repeatStringNumTimesWithWhile('abc', 0);
2742
expect(result).toBe('');
2843
});
2944

30-
test('do-while-loop', () => {
31-
let result = repeatStringNumTimesWithDoWhile('abc', 3);
45+
test('num = -2', () => {
46+
const result = repeatStringNumTimesWithWhile('abc', -2);
47+
expect(result).toBe('');
48+
});
49+
});
50+
51+
describe('step2-3 with do-while-loop', () => {
52+
test('num = 3', () => {
53+
const result = repeatStringNumTimesWithDoWhile('abc', 3);
3254
expect(result).toBe('abcabcabc');
55+
});
3356

34-
result = repeatStringNumTimesWithFor('abc', 1);
57+
test('num = 1', () => {
58+
const result = repeatStringNumTimesWithDoWhile('abc', 1);
3559
expect(result).toBe('abc');
60+
});
61+
62+
test('num = 0', () => {
63+
const result = repeatStringNumTimesWithDoWhile('abc', 0);
64+
expect(result).toBe('');
65+
});
3666

37-
result = repeatStringNumTimesWithFor('abc', -2);
67+
test('num = -2', () => {
68+
const result = repeatStringNumTimesWithDoWhile('abc', -2);
3869
expect(result).toBe('');
3970
});
4071
});

Week3/test/step2-4.test.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
const hound = require('../homework/step2-4');
22

3-
test('4-step3', () => {
4-
expect(typeof hound).toBe('object');
5-
expect(typeof hound.name).toBe('string');
6-
expect(typeof hound.color).toBe('string');
7-
expect(typeof hound.numLegs).toBe('number');
3+
describe('step2-4', () => {
4+
test('hound to be an object', () => {
5+
expect(typeof hound).toBe('object');
6+
});
7+
8+
test('hound.name to be a string', () => {
9+
expect(typeof hound.name).toBe('string');
10+
});
11+
12+
test('hound.color to be a string', () => {
13+
expect(typeof hound.color).toBe('string');
14+
});
15+
16+
test('hound.numLegs to be a number', () => {
17+
expect(typeof hound.numLegs).toBe('number');
18+
});
819
});

Week3/test/step2-5.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const multiplyAll = require('../homework/step2-5');
22

3-
test('5-step3.js', () => {
4-
const result = multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);
5-
expect(result).toBe(5040);
3+
describe('step2-5', () => {
4+
test('result to be product of array elements', () => {
5+
const result = multiplyAll([[1, 2], [3, 4], [5, 6, 7]]);
6+
expect(result).toBe(5040);
7+
});
68
});

Week3/test/step2-6.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-return-assign, dot-notation */
12
const { printArray2d, printArray3d } = require('../homework/step2-6');
23

34
const arr2d = [[1, 2], [3, 4], [5, 6]];
@@ -6,18 +7,18 @@ const expected2d = [1, 2, 3, 4, 5, 6].join('');
67
const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
78
const expected3d = [1, 2, 3, 4, 5, 6, 7, 8].join('');
89

9-
describe('6-step3.js', () => {
10+
describe('step2-6', () => {
1011
let outputData;
1112
const storeLog = (...inputs) => (outputData += inputs.join(' '));
1213

13-
test('printArray2d', () => {
14+
test('printArray2d -> 1, 2, 3, 4, 5, 6', () => {
1415
outputData = '';
1516
console['log'] = jest.fn(storeLog);
1617
printArray2d(arr2d);
1718
expect(outputData).toBe(expected2d);
1819
});
1920

20-
test('printArray2d', () => {
21+
test('printArray3d -> 1, 2, 3, 4, 5, 6, 7, 8', () => {
2122
outputData = '';
2223
console['log'] = jest.fn(storeLog);
2324
printArray3d(arr3d);

Week3/test/step3-bonus.test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const makeUnique = require(`../homework/step3-bonus`);
22

3-
test('step4-bonus', () => {
4-
const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
5-
const expected = ['a', 'b', 'c', 'd', 'e', 'f'];
6-
const result = makeUnique(values);
7-
expect(result).toEqual(expected);
3+
describe('step3-bonus', () => {
4+
test('array should not contain duplicates', () => {
5+
const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
6+
const expected = ['a', 'b', 'c', 'd', 'e', 'f'];
7+
const result = makeUnique(values);
8+
expect(result).toEqual(expected);
9+
});
810
});

Week3/test/step3.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
const createBase = require(`../homework/step3`);
22

3-
test('step4.js', () => {
4-
const addSix = createBase(6);
5-
const result = addSix(10);
6-
expect(result).toBe(16);
3+
describe('step3', () => {
4+
test('base = 6', () => {
5+
const addSix = createBase(6);
6+
const result = addSix(10);
7+
expect(result).toBe(16);
8+
});
9+
10+
test('base = 10', () => {
11+
const addTen = createBase(10);
12+
const result = addTen(10);
13+
expect(result).toBe(20);
14+
});
715
});

0 commit comments

Comments
 (0)