@@ -190,4 +190,36 @@ describe('actions/Policy', () => {
190
190
} ) ;
191
191
} ) ;
192
192
} ) ;
193
+
194
+ describe ( 'upgradeToCorporate' , ( ) => {
195
+ it ( 'upgradeToCorporate should not alter initial values of autoReporting and autoReportingFrequency' , async ( ) => {
196
+ const autoReporting = true ;
197
+ const autoReportingFrequency = CONST . POLICY . AUTO_REPORTING_FREQUENCIES . INSTANT ;
198
+ // Given that a policy has autoReporting initially set to true and autoReportingFrequency set to instant.
199
+ const fakePolicy : PolicyType = {
200
+ ...createRandomPolicy ( 0 , CONST . POLICY . TYPE . TEAM ) ,
201
+ autoReporting,
202
+ autoReportingFrequency,
203
+ } ;
204
+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . POLICY } ${ fakePolicy . id } ` , fakePolicy ) ;
205
+
206
+ // When a policy is upgradeToCorporate
207
+ Policy . upgradeToCorporate ( fakePolicy . id ) ;
208
+ await waitForBatchedUpdates ( ) ;
209
+
210
+ const policy : OnyxEntry < PolicyType > = await new Promise ( ( resolve ) => {
211
+ const connection = Onyx . connect ( {
212
+ key : `${ ONYXKEYS . COLLECTION . POLICY } ${ fakePolicy . id } ` ,
213
+ callback : ( workspace ) => {
214
+ Onyx . disconnect ( connection ) ;
215
+ resolve ( workspace ) ;
216
+ } ,
217
+ } ) ;
218
+ } ) ;
219
+
220
+ // Then the policy autoReporting and autoReportingFrequency should equal the initial value.
221
+ expect ( policy ?. autoReporting ) . toBe ( autoReporting ) ;
222
+ expect ( policy ?. autoReportingFrequency ) . toBe ( autoReportingFrequency ) ;
223
+ } ) ;
224
+ } ) ;
193
225
} ) ;
0 commit comments