@@ -64,22 +64,26 @@ describe('GitHooksService', () => {
6464 describe ( 'detectUnityGitHooks' , ( ) => {
6565 it ( 'should return true when package is in manifest.json' , ( ) => {
6666 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
67- ( mockFs . readFileSync as jest . Mock ) . mockReturnValue ( JSON . stringify ( {
68- dependencies : {
69- 'com.frostebite.unitygithooks' : 'https://github.com/frostebite/UnityGitHooks.git#1.0.5' ,
70- } ,
71- } ) ) ;
67+ ( mockFs . readFileSync as jest . Mock ) . mockReturnValue (
68+ JSON . stringify ( {
69+ dependencies : {
70+ 'com.frostebite.unitygithooks' : 'https://github.com/frostebite/UnityGitHooks.git#1.0.5' ,
71+ } ,
72+ } ) ,
73+ ) ;
7274
7375 expect ( GitHooksService . detectUnityGitHooks ( '/repo' ) ) . toBe ( true ) ;
7476 } ) ;
7577
7678 it ( 'should return false when package is not in manifest.json' , ( ) => {
7779 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
78- ( mockFs . readFileSync as jest . Mock ) . mockReturnValue ( JSON . stringify ( {
79- dependencies : {
80- 'com.unity.textmeshpro' : '3.0.6' ,
81- } ,
82- } ) ) ;
80+ ( mockFs . readFileSync as jest . Mock ) . mockReturnValue (
81+ JSON . stringify ( {
82+ dependencies : {
83+ 'com.unity.textmeshpro' : '3.0.6' ,
84+ } ,
85+ } ) ,
86+ ) ;
8387
8488 expect ( GitHooksService . detectUnityGitHooks ( '/repo' ) ) . toBe ( false ) ;
8589 } ) ;
@@ -115,9 +119,7 @@ describe('GitHooksService', () => {
115119
116120 it ( 'should return empty string when package not in cache' , ( ) => {
117121 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
118- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
119- 'com.unity.textmeshpro@3.0.6' ,
120- ] ) ;
122+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.unity.textmeshpro@3.0.6' ] ) ;
121123
122124 const result = GitHooksService . findUnityGitHooksPackagePath ( '/repo' ) ;
123125 expect ( result ) . toBe ( '' ) ;
@@ -136,16 +138,11 @@ describe('GitHooksService', () => {
136138 const { OrchestratorSystem } = require ( '../core/orchestrator-system' ) ;
137139
138140 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
139- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
140- 'com.frostebite.unitygithooks@1.0.5' ,
141- ] ) ;
141+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.frostebite.unitygithooks@1.0.5' ] ) ;
142142
143143 await GitHooksService . initUnityGitHooks ( '/repo' ) ;
144144
145- expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith (
146- expect . stringContaining ( 'init-unity-lefthook.js' ) ,
147- true ,
148- ) ;
145+ expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith ( expect . stringContaining ( 'init-unity-lefthook.js' ) , true ) ;
149146 } ) ;
150147
151148 it ( 'should skip when package not found in cache' , async ( ) => {
@@ -165,32 +162,24 @@ describe('GitHooksService', () => {
165162 // PackageCache dir exists, but init script doesn't
166163 return ! String ( p ) . includes ( 'init-unity-lefthook' ) ;
167164 } ) ;
168- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
169- 'com.frostebite.unitygithooks@1.0.5' ,
170- ] ) ;
165+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.frostebite.unitygithooks@1.0.5' ] ) ;
171166
172167 await GitHooksService . initUnityGitHooks ( '/repo' ) ;
173168
174- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
175- expect . stringContaining ( 'init script not found' ) ,
176- ) ;
169+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'init script not found' ) ) ;
177170 } ) ;
178171
179172 it ( 'should log warning on init failure' , async ( ) => {
180173 const { OrchestratorSystem } = require ( '../core/orchestrator-system' ) ;
181174 const OrchestratorLogger = require ( '../core/orchestrator-logger' ) . default ;
182175
183176 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
184- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
185- 'com.frostebite.unitygithooks@1.0.5' ,
186- ] ) ;
177+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.frostebite.unitygithooks@1.0.5' ] ) ;
187178 OrchestratorSystem . Run . mockRejectedValue ( new Error ( 'node not found' ) ) ;
188179
189180 await GitHooksService . initUnityGitHooks ( '/repo' ) ;
190181
191- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
192- expect . stringContaining ( 'init failed' ) ,
193- ) ;
182+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'init failed' ) ) ;
194183 } ) ;
195184 } ) ;
196185
@@ -228,9 +217,7 @@ describe('GitHooksService', () => {
228217 ( mockFs . readFileSync as jest . Mock ) . mockReturnValue (
229218 `{"dependencies":{"com.frostebite.unitygithooks":"https://github.com/frostebite/UnityGitHooks.git"}}` ,
230219 ) ;
231- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
232- 'com.frostebite.unitygithooks@1.0.5' ,
233- ] ) ;
220+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.frostebite.unitygithooks@1.0.5' ] ) ;
234221
235222 OrchestratorSystem . Run . mockImplementation ( ( cmd : string ) => {
236223 if ( cmd . includes ( 'init-unity-lefthook' ) ) {
@@ -246,19 +233,13 @@ describe('GitHooksService', () => {
246233
247234 // Init should happen before install
248235 expect ( callOrder ) . toEqual ( [ 'init' , 'install' ] ) ;
249- expect ( OrchestratorLogger . log ) . toHaveBeenCalledWith (
250- expect . stringContaining ( 'Unity Git Hooks (UPM) detected' ) ,
251- ) ;
236+ expect ( OrchestratorLogger . log ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Unity Git Hooks (UPM) detected' ) ) ;
252237 } ) ;
253238
254239 it ( 'should set CI env vars when Unity Git Hooks detected' , async ( ) => {
255240 ( mockFs . existsSync as jest . Mock ) . mockReturnValue ( true ) ;
256- ( mockFs . readFileSync as jest . Mock ) . mockReturnValue (
257- `{"dependencies":{"com.frostebite.unitygithooks":"1.0.5"}}` ,
258- ) ;
259- ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [
260- 'com.frostebite.unitygithooks@1.0.5' ,
261- ] ) ;
241+ ( mockFs . readFileSync as jest . Mock ) . mockReturnValue ( `{"dependencies":{"com.frostebite.unitygithooks":"1.0.5"}}` ) ;
242+ ( mockFs . readdirSync as jest . Mock ) . mockReturnValue ( [ 'com.frostebite.unitygithooks@1.0.5' ] ) ;
262243
263244 await GitHooksService . installHooks ( '/repo' ) ;
264245
@@ -300,9 +281,7 @@ describe('GitHooksService', () => {
300281
301282 await GitHooksService . installHooks ( '/repo' ) ;
302283
303- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
304- expect . stringContaining ( 'Hook installation failed' ) ,
305- ) ;
284+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Hook installation failed' ) ) ;
306285 } ) ;
307286 } ) ;
308287
@@ -316,14 +295,8 @@ describe('GitHooksService', () => {
316295
317296 const results = await GitHooksService . runHookGroups ( '/repo' , [ 'pre-commit' , 'pre-push' ] ) ;
318297
319- expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith (
320- `cd "/repo" && npx lefthook run pre-commit` ,
321- true ,
322- ) ;
323- expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith (
324- `cd "/repo" && npx lefthook run pre-push` ,
325- true ,
326- ) ;
298+ expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith ( `cd "/repo" && npx lefthook run pre-commit` , true ) ;
299+ expect ( OrchestratorSystem . Run ) . toHaveBeenCalledWith ( `cd "/repo" && npx lefthook run pre-push` , true ) ;
327300 expect ( results [ 'pre-commit' ] ) . toBe ( true ) ;
328301 expect ( results [ 'pre-push' ] ) . toBe ( true ) ;
329302 } ) ;
@@ -340,9 +313,7 @@ describe('GitHooksService', () => {
340313 const results = await GitHooksService . runHookGroups ( '/repo' , [ 'pre-commit' ] ) ;
341314
342315 expect ( results ) . toEqual ( { } ) ;
343- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
344- expect . stringContaining ( 'requires lefthook' ) ,
345- ) ;
316+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'requires lefthook' ) ) ;
346317 } ) ;
347318
348319 it ( 'should mark failed groups as false' , async ( ) => {
@@ -351,8 +322,7 @@ describe('GitHooksService', () => {
351322 return String ( filePath ) . includes ( 'lefthook.yml' ) && ! String ( filePath ) . startsWith ( '.' ) ;
352323 } ) ;
353324
354- OrchestratorSystem . Run
355- . mockResolvedValueOnce ( '' ) // pre-commit passes
325+ OrchestratorSystem . Run . mockResolvedValueOnce ( '' ) // pre-commit passes
356326 . mockRejectedValueOnce ( new Error ( 'tests failed' ) ) ; // pre-push fails
357327
358328 const results = await GitHooksService . runHookGroups ( '/repo' , [ 'pre-commit' , 'pre-push' ] ) ;
@@ -368,18 +338,12 @@ describe('GitHooksService', () => {
368338 return String ( filePath ) . includes ( 'lefthook.yml' ) && ! String ( filePath ) . startsWith ( '.' ) ;
369339 } ) ;
370340
371- OrchestratorSystem . Run
372- . mockResolvedValueOnce ( '' )
373- . mockRejectedValueOnce ( new Error ( 'check failed' ) ) ;
341+ OrchestratorSystem . Run . mockResolvedValueOnce ( '' ) . mockRejectedValueOnce ( new Error ( 'check failed' ) ) ;
374342
375343 await GitHooksService . runHookGroups ( '/repo' , [ 'pre-commit' , 'commit-msg' ] ) ;
376344
377- expect ( OrchestratorLogger . log ) . toHaveBeenCalledWith (
378- expect . stringContaining ( "'pre-commit' passed" ) ,
379- ) ;
380- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
381- expect . stringContaining ( "'commit-msg' failed" ) ,
382- ) ;
345+ expect ( OrchestratorLogger . log ) . toHaveBeenCalledWith ( expect . stringContaining ( "'pre-commit' passed" ) ) ;
346+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( "'commit-msg' failed" ) ) ;
383347 } ) ;
384348 } ) ;
385349
@@ -429,9 +393,7 @@ describe('GitHooksService', () => {
429393
430394 await GitHooksService . disableHooks ( '/repo' ) ;
431395
432- expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith (
433- expect . stringContaining ( 'Failed to disable hooks' ) ,
434- ) ;
396+ expect ( OrchestratorLogger . logWarning ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Failed to disable hooks' ) ) ;
435397 } ) ;
436398 } ) ;
437399
0 commit comments