@@ -351,9 +351,37 @@ describe("updateLocalFiles", () => {
351
351
` ) ;
352
352
} ) ;
353
353
354
+ it ( "does not replace an existing description when it does not exist" , async ( ) => {
355
+ mockReadFileSafeAsJson . mockResolvedValue ( { } ) ;
356
+ mockReplaceInFile . mockResolvedValue ( [ ] ) ;
357
+
358
+ await updateLocalFiles ( options , "initialize" ) ;
359
+
360
+ expect ( mockReplaceInFile ) . not . toHaveBeenCalledWith ( {
361
+ files : [ "./.github/**/*" , "./*.*" ] ,
362
+ from : expect . anything ( ) ,
363
+ to : options . description ,
364
+ } ) ;
365
+ } ) ;
366
+ it ( "replaces an existing description when it exists" , async ( ) => {
367
+ const existingDescription = "Existing description." ;
368
+
369
+ mockReadFileSafeAsJson . mockResolvedValue ( {
370
+ description : existingDescription ,
371
+ } ) ;
372
+ mockReplaceInFile . mockResolvedValue ( [ ] ) ;
373
+
374
+ await updateLocalFiles ( options , "initialize" ) ;
375
+
376
+ expect ( mockReplaceInFile ) . toHaveBeenCalledWith ( {
377
+ files : [ "./.github/**/*" , "./*.*" ] ,
378
+ from : existingDescription ,
379
+ to : options . description ,
380
+ } ) ;
381
+ } ) ;
382
+
354
383
it ( "removes bin when the mode is initialize" , async ( ) => {
355
384
mockReadFileSafeAsJson . mockResolvedValue ( {
356
- description : "Existing description" ,
357
385
version : "1.2.3" ,
358
386
} ) ;
359
387
mockReplaceInFile . mockResolvedValue ( [ ] ) ;
@@ -369,7 +397,6 @@ describe("updateLocalFiles", () => {
369
397
370
398
it ( "does not remove bin when the mode is migrate" , async ( ) => {
371
399
mockReadFileSafeAsJson . mockResolvedValue ( {
372
- description : "Existing description" ,
373
400
version : "1.2.3" ,
374
401
} ) ;
375
402
mockReplaceInFile . mockResolvedValue ( [ ] ) ;
@@ -385,7 +412,6 @@ describe("updateLocalFiles", () => {
385
412
386
413
it ( "resets package version to 0.0.0 when mode is initialize" , async ( ) => {
387
414
mockReadFileSafeAsJson . mockResolvedValue ( {
388
- description : "Existing description" ,
389
415
version : "1.2.3" ,
390
416
} ) ;
391
417
mockReplaceInFile . mockResolvedValue ( [ ] ) ;
@@ -401,7 +427,6 @@ describe("updateLocalFiles", () => {
401
427
402
428
it ( "does not reset package version to 0.0.0 when mode is migrate" , async ( ) => {
403
429
mockReadFileSafeAsJson . mockResolvedValue ( {
404
- description : "Existing description" ,
405
430
version : "1.2.3" ,
406
431
} ) ;
407
432
mockReplaceInFile . mockResolvedValue ( [ ] ) ;
0 commit comments