Skip to content

Commit efe6b98

Browse files
authored
Update test.js
1 parent dd81a89 commit efe6b98

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

exercises/22-Matrix-Builder/test.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ test('The matrix should have the ammount of rows and columns required as paramet
2929
});
3030

3131
test('The matrix should only have 0 or 1 as values.', function(){
32-
for(let i = 0; i < 5; i++){
33-
for(let j = 0; j < 5; j++){
34-
let condition = false;
35-
if(_test[i][j] == 0 || _test[i][j]== 1){
36-
condition = true;
37-
}
38-
expect(condition).toBeTruthy();
39-
}
40-
}
41-
});
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+
});

0 commit comments

Comments
 (0)