File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
exercises/22-Matrix-Builder Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -29,13 +29,18 @@ test('The matrix should have the ammount of rows and columns required as paramet
2929} ) ;
3030
3131test ( '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+ } ) ;
You can’t perform that action at this time.
0 commit comments