File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,36 @@ describe("Simple Git Hooks tests", () => {
361
361
expect ( isEqual ( installedHooks , { } ) ) . toBe ( true ) ;
362
362
} ) ;
363
363
364
+ it ( "only removes git hooks which are not in preserveUnused" , ( ) => {
365
+ createGitHooksFolder ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
366
+
367
+ fs . writeFileSync (
368
+ path . join ( path . normalize (
369
+ path . join ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
370
+ ) , "commit-msg" ) ,
371
+ TEST_SCRIPT
372
+ ) ;
373
+
374
+ let installedHooks = getInstalledGitHooks (
375
+ path . normalize (
376
+ path . join ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
377
+ )
378
+ ) ;
379
+
380
+ simpleGitHooks . setHooksFromConfig ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
381
+
382
+ expect ( isEqual ( installedHooks , { "pre-commit" : TEST_SCRIPT , "commit-msg" : TEST_SCRIPT } ) ) . toBe ( true ) ;
383
+
384
+ simpleGitHooks . removeHooks ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON ) ;
385
+
386
+ installedHooks = getInstalledGitHooks (
387
+ path . normalize (
388
+ path . join ( PROJECT_WITH_UNUSED_CONF_IN_PACKAGE_JSON , ".git" , "hooks" )
389
+ )
390
+ ) ;
391
+ expect ( isEqual ( installedHooks , { "commit-msg" : TEST_SCRIPT } ) ) . toBe ( true ) ;
392
+ } ) ;
393
+
364
394
it ( "creates git hooks and removes unused git hooks" , ( ) => {
365
395
createGitHooksFolder ( PROJECT_WITH_CONF_IN_PACKAGE_JSON ) ;
366
396
You can’t perform that action at this time.
0 commit comments