Skip to content

Commit a7e40c1

Browse files
authored
Merge branch 'master' into patch-1
2 parents 337fc77 + 3309a15 commit a7e40c1

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

exercises/19-And-One-and-a-Two-and-a-Three/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ let contact = {
66
for(let key in contact){
77
// Code goes here
88
}
9+

exercises/21.3-Filter-list/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test('The output in the console should match the one in the instructions!', func
2626

2727
//declare your function here
2828
function _filterByName(theArray, theString){
29-
let filteredArray = theArray.filter(item => item.includes(theString))
29+
let filteredArray = theArray.filter(item => item.toLowerCase().includes(theString.toLowerCase()))
3030
return filteredArray
3131
}
3232

exercises/22-Matrix-Builder/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ This number represents the amount of rows and columns for the matrix. Example:
1111
This function should return an array of arrays that represents the matrix. Example: 3 should return:
1212
```md
1313
[
14-
[1, 1, 1],
15-
[1, 1, 1],
16-
[1, 1, 1]
14+
[0, 1, 1],
15+
[1, 0, 1],
16+
[0, 0, 0]
1717
]
1818
```
1919

exercises/22-Matrix-Builder/test.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ global.console.log = console.log = jest.fn((text) => _buffer += text + "\n");
88

99
const app_content = fs.readFileSync(path.resolve(__dirname, './app.js'), 'utf8');
1010

11-
test("You should create a function named matrixBuilder", function(){
11+
test("You should create a function named matrixBuilder.", function(){
1212
const file = rewire("./app.js");
1313
const myFunc = file.__get__('matrixBuilder');
1414
expect(myFunc).toBeTruthy();
@@ -19,25 +19,28 @@ test('You have to use the console.log function to print the correct output.', fu
1919
expect(console.log.mock.calls.length > 0).toBe(true);
2020
});
2121

22-
test('The output in the console should match the one in the instructions!', function () {
23-
const _app = rewire('./app.js');
24-
25-
function matrixBuilder(matrix){
26-
let newMatrix = [];
27-
let newArray = [];
28-
for (let x =0; x < matrix; x++){
29-
newMatrix.push(newArray)
30-
}
31-
for (let i =0; i < matrix; i++){
32-
newArray.push(1)
33-
}
34-
return newMatrix
35-
}
36-
37-
let _test = matrixBuilder(5)
38-
expect(_buffer).toMatch(_test.map(n => n).join(","));
39-
});
40-
41-
22+
test('The matrix should have the ammount of rows and columns required as parameter.', function () {
23+
const file = rewire("./app.js");
24+
const myFunc = file.__get__('matrixBuilder');
4225

26+
let _test = myFunc(5);
27+
expect(_test.length.toString()).toMatch("5");
28+
expect(_test[0].length.toString()).toMatch("5");
29+
});
4330

31+
test('The matrix should only have 0 or 1 as values.', function(){
32+
const file = rewire("./app.js");
33+
const myFunc = file.__get__('matrixBuilder');
34+
let _test = myFunc(5);
35+
let findCero = false;
36+
let findOne = false;
37+
_test.forEach(row => {
38+
row.forEach(item => {
39+
if(item == 0) findCero = true;
40+
else if(item == 1) findOne = true;
41+
else throw new Exception("The matrix contains other items rather than 0 and 1")
42+
})
43+
})
44+
expect(findCero).toBe(true);
45+
expect(findOne).toBe(true);
46+
});

exercises/25-Techno-beat/test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test('The output in the console should match the one in the instructions!', func
3636
}
3737
}
3838
}
39-
return string
39+
return string.trim()
4040
}
4141

4242

@@ -45,11 +45,11 @@ test('The output in the console should match the one in the instructions!', func
4545
let _test3 = _lyricsGenerator([0,0,0])
4646
let _test4 = _lyricsGenerator([1,0,1])
4747
let _test5 = _lyricsGenerator([1,1,1])
48-
expect(console.log).toHaveBeenCalledWith(_test1);
49-
expect(console.log).toHaveBeenCalledWith(_test2);
50-
expect(console.log).toHaveBeenCalledWith(_test3);
51-
expect(console.log).toHaveBeenCalledWith(_test4);
52-
expect(console.log).toHaveBeenCalledWith(_test5);
48+
expect(console.log.trim()).toHaveBeenCalledWith(_test1);
49+
expect(console.log.trim()).toHaveBeenCalledWith(_test2);
50+
expect(console.log.trim()).toHaveBeenCalledWith(_test3);
51+
expect(console.log.trim()).toHaveBeenCalledWith(_test4);
52+
expect(console.log.trim()).toHaveBeenCalledWith(_test5);
5353
});
5454

5555

0 commit comments

Comments
 (0)