@@ -2,22 +2,36 @@ const fs = require('fs');
22const assert = require ( 'assert' ) ;
33const path = require ( 'path' ) ;
44const sinon = require ( 'sinon' ) ;
5+ const expect = require ( 'chai' ) . expect ;
56
67const config = require ( '../config/config' ) . settings ;
78const Coverage = require ( '../coverage' ) ;
89
910const dummy_id = '1c33a6e2ac7d7fc098105b21a702e104e09767cf' ;
1011
1112
12- xdescribe ( 'Test coverage parser:' , function ( ) {
13+ describe ( 'Test coverage parser:' , function ( ) {
1314 var testable ;
15+ var sandbox ;
1416 // Check NODE_ENV is correctly set, meaning our imported settings will be test ones
15- before ( function ( ) {
16- assert ( process . env . NODE_ENV . startsWith ( 'test' ) , 'Test run outside test env' )
17+ beforeEach ( function ( ) {
18+ let md5 = '385a5d56850127317c317b0f66e91078' ;
19+ let code = 'line1\nline2\n\rline3\n\rline4' ;
1720 testable = function ( obj , done ) {
18- assert ( obj . source_files ) ;
21+ expect ( [ 291 , 63 ] ) . to . include ( obj . source_files . length ) ;
22+ let file = obj . source_files [ 0 ] ;
23+ expect ( file ) . to . have . all . keys ( 'name' , 'source_digest' , 'coverage' ) ;
24+ expect ( file [ 'source_digest' ] ) . to . eq ( md5 ) ;
1925 done ( ) ;
2026 } ;
27+ sandbox = sinon . createSandbox ( ) ;
28+ sandbox
29+ . stub ( fs , 'readFileSync' )
30+ . withArgs ( sinon . match ( ( x ) => x . replace ( '\\' , '/' ) . startsWith ( 'C:/Rigbox' ) ) )
31+ . returns ( code )
32+ . withArgs ( sinon . match ( ( x ) => x . replace ( '\\' , '/' ) . startsWith ( 'C:/ibllib' ) ) )
33+ . returns ( code ) ;
34+ fs . readFileSync . callThrough ( ) ;
2135 } )
2236
2337 it ( 'Check loading MATLAB' , function ( done ) {
@@ -27,8 +41,10 @@ xdescribe('Test coverage parser:', function() {
2741
2842 it ( 'Check loading Python' , function ( done ) {
2943 let xmlPath = path . resolve ( 'test' , 'fixtures' , 'CoverageResults.py.xml' )
30- Coverage ( xmlPath , '' , dummy_id , obj => testable ( obj , done ) ) ;
44+ Coverage ( xmlPath , 'ibllib ' , dummy_id , obj => testable ( obj , done ) ) ;
3145 } ) ;
46+
47+ afterEach ( function ( ) { sandbox . restore ( ) ; } ) ;
3248} ) ;
3349
3450
0 commit comments