@@ -7,7 +7,7 @@ const chai = require("chai"),
77const fs = require ( 'fs' ) ,
88 path = require ( 'path' ) ,
99 request = require ( 'request' ) ,
10- unzipper = require ( 'unzipper ' ) ;
10+ decompress = require ( 'decompress ' ) ;
1111 Constants = require ( "../../../../bin/helpers/constants" ) ,
1212 logger = require ( "../../../../bin/helpers/logger" ) . winstonLogger ,
1313 testObjects = require ( "../../support/fixtures/testObjects" ) ,
@@ -241,6 +241,40 @@ describe("calls API to generate report", () => {
241241 } ) ;
242242} ) ;
243243
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+
244278describe ( "generateCypressBuildReport" , ( ) => {
245279 var sandbox ;
246280 beforeEach ( ( ) => {
0 commit comments