@@ -7,7 +7,7 @@ const chai = require("chai"),
7
7
const fs = require ( 'fs' ) ,
8
8
path = require ( 'path' ) ,
9
9
request = require ( 'request' ) ,
10
- unzipper = require ( 'unzipper ' ) ;
10
+ decompress = require ( 'decompress ' ) ;
11
11
Constants = require ( "../../../../bin/helpers/constants" ) ,
12
12
logger = require ( "../../../../bin/helpers/logger" ) . winstonLogger ,
13
13
testObjects = require ( "../../support/fixtures/testObjects" ) ,
@@ -241,6 +241,40 @@ describe("calls API to generate report", () => {
241
241
} ) ;
242
242
} ) ;
243
243
244
+ describe ( "unzipFile" , ( ) => {
245
+ var sandbox ;
246
+ beforeEach ( ( ) => {
247
+ sandbox = sinon . createSandbox ( ) ;
248
+ } ) ;
249
+
250
+ afterEach ( ( ) => {
251
+ sandbox . restore ( ) ;
252
+ sinon . restore ( ) ;
253
+ } ) ;
254
+
255
+ it ( "calls unzip and resolves with success message" , ( ) => {
256
+ let pathStub = sinon . stub ( path , 'join' ) ;
257
+ pathStub . calledOnceWith ( 'abc' , 'efg.txt' ) ;
258
+ let decompressStub = sandbox . stub ( ) . returns ( Promise . resolve ( "Unzipped the json and html successfully." ) ) ;
259
+ let rewireReporterHTML = rewire ( '../../../../bin/helpers/reporterHTML' ) ;
260
+ rewireReporterHTML . __set__ ( 'decompress' , decompressStub ) ;
261
+ let unzipFile = rewireReporterHTML . __get__ ( 'unzipFile' )
262
+ unzipFile ( 'abc' , 'efg' ) ;
263
+ } ) ;
264
+
265
+ it ( "calls unzip and rejects with error message on failure" , ( ) => {
266
+ let pathStub = sinon . stub ( path , 'join' ) ;
267
+ pathStub . calledOnceWith ( 'abc' , 'efg.txt' ) ;
268
+ let processStub = sinon . stub ( process , 'exit' ) ;
269
+ processStub . returns ( Constants . ERROR_EXIT_CODE )
270
+ let decompressStub = sandbox . stub ( ) . returns ( Promise . reject ( "Error" ) ) ;
271
+ let rewireReporterHTML = rewire ( '../../../../bin/helpers/reporterHTML' ) ;
272
+ rewireReporterHTML . __set__ ( 'decompress' , decompressStub ) ;
273
+ let unzipFile = rewireReporterHTML . __get__ ( 'unzipFile' )
274
+ unzipFile ( 'abc' , 'efg' ) ;
275
+ } ) ;
276
+ } ) ;
277
+
244
278
describe ( "generateCypressBuildReport" , ( ) => {
245
279
var sandbox ;
246
280
beforeEach ( ( ) => {
0 commit comments