@@ -8,42 +8,32 @@ import { collectAndPersistReports } from './collect-and-persist';
88import { collect } from './implementation/collect' ;
99import { logPersistedResults , persistReport } from './implementation/persist' ;
1010
11- vi . mock ( './implementation/collect' , async ( ) => {
12- return {
13- collect : vi . fn ( ) . mockImplementation (
14- async ( ) =>
15- ( {
16- packageName : 'code-pushup' ,
17- version : '0.0.1' ,
18- date : new Date ( ) . toISOString ( ) ,
19- duration : 0 ,
20- categories : [ ] ,
21- plugins : [ ] ,
22- } as Report ) ,
23- ) ,
24- } ;
25- } ) ;
11+ vi . mock ( './implementation/collect' , ( ) => ( {
12+ collect : vi . fn ( ) . mockResolvedValue ( {
13+ packageName : 'code-pushup' ,
14+ version : '0.0.1' ,
15+ date : new Date ( ) . toISOString ( ) ,
16+ duration : 0 ,
17+ categories : [ ] ,
18+ plugins : [ ] ,
19+ } as Report ) ,
20+ } ) ) ;
2621
27- vi . mock ( './implementation/persist' , async ( ) => {
28- return {
29- persistReport : vi . fn ( ) . mockImplementation ( async ( ) => ( { } ) ) ,
30- logPersistedResults : vi . fn ( ) . mockReturnValue ( undefined ) ,
31- } ;
32- } ) ;
22+ vi . mock ( './implementation/persist' , ( ) => ( {
23+ persistReport : vi . fn ( ) ,
24+ logPersistedResults : vi . fn ( ) ,
25+ } ) ) ;
3326
3427describe ( 'collectAndPersistReports' , ( ) => {
3528 it ( 'should call collect and persistReport with correct parameters in non-verbose mode' , async ( ) => {
36- await collectAndPersistReports ( {
29+ const nonVerboseConfig = {
3730 ...MINIMAL_CONFIG_MOCK ,
3831 verbose : false ,
3932 progress : false ,
40- } ) ;
33+ } ;
34+ await collectAndPersistReports ( nonVerboseConfig ) ;
4135
42- expect ( collect ) . toHaveBeenCalledWith ( {
43- ...MINIMAL_CONFIG_MOCK ,
44- verbose : false ,
45- progress : false ,
46- } ) ;
36+ expect ( collect ) . toHaveBeenCalledWith ( nonVerboseConfig ) ;
4737
4838 expect ( persistReport ) . toHaveBeenCalledWith (
4939 {
@@ -54,28 +44,21 @@ describe('collectAndPersistReports', () => {
5444 categories : [ ] ,
5545 plugins : [ ] ,
5646 } ,
57- {
58- ...MINIMAL_CONFIG_MOCK ,
59- verbose : false ,
60- progress : false ,
61- } ,
47+ nonVerboseConfig ,
6248 ) ;
6349
6450 expect ( logPersistedResults ) . not . toHaveBeenCalled ( ) ;
6551 } ) ;
6652
6753 it ( 'should call collect and persistReport with correct parameters in verbose mode' , async ( ) => {
68- await collectAndPersistReports ( {
54+ const verboseConfig = {
6955 ...MINIMAL_CONFIG_MOCK ,
7056 verbose : true ,
7157 progress : false ,
72- } ) ;
58+ } ;
59+ await collectAndPersistReports ( verboseConfig ) ;
7360
74- expect ( collect ) . toHaveBeenCalledWith ( {
75- ...MINIMAL_CONFIG_MOCK ,
76- verbose : true ,
77- progress : false ,
78- } ) ;
61+ expect ( collect ) . toHaveBeenCalledWith ( verboseConfig ) ;
7962
8063 expect ( persistReport ) . toHaveBeenCalledWith (
8164 {
@@ -86,11 +69,7 @@ describe('collectAndPersistReports', () => {
8669 categories : [ ] ,
8770 plugins : [ ] ,
8871 } as Report ,
89- {
90- ...MINIMAL_CONFIG_MOCK ,
91- verbose : true ,
92- progress : false ,
93- } ,
72+ verboseConfig ,
9473 ) ;
9574
9675 expect ( logPersistedResults ) . toHaveBeenCalled ( ) ;
0 commit comments