@@ -50,54 +50,75 @@ describe('clean (unified) tool', () => {
5050 } ) ;
5151
5252 it ( 'uses iOS platform by default' , async ( ) => {
53- const mock = createMockExecutor ( { success : true , output : 'clean success' } ) ;
54- const result = await cleanLogic ( { projectPath : '/p.xcodeproj' , scheme : 'App' } as any , mock ) ;
53+ let capturedCommand : string [ ] = [ ] ;
54+ const mockExecutor = async ( command : string [ ] ) => {
55+ capturedCommand = command ;
56+ return { success : true , output : 'clean success' } ;
57+ } ;
58+
59+ const result = await cleanLogic (
60+ { projectPath : '/p.xcodeproj' , scheme : 'App' } as any ,
61+ mockExecutor ,
62+ ) ;
5563 expect ( result . isError ) . not . toBe ( true ) ;
56-
57- // Check that the executor was called with iOS platform arguments
58- expect ( mock ) . toHaveBeenCalled ( ) ;
59- const commandArgs = mock . mock . calls [ 0 ] [ 0 ] ;
60- expect ( commandArgs ) . toContain ( '-destination' ) ;
61- expect ( commandArgs ) . toContain ( 'platform=iOS' ) ;
64+
65+ // Check that the command contains iOS platform destination
66+ const commandStr = capturedCommand . join ( ' ' ) ;
67+ expect ( commandStr ) . toContain ( '-destination' ) ;
68+ expect ( commandStr ) . toContain ( 'platform=iOS' ) ;
6269 } ) ;
6370
6471 it ( 'accepts custom platform parameter' , async ( ) => {
65- const mock = createMockExecutor ( { success : true , output : 'clean success' } ) ;
66- const result = await cleanLogic ( {
67- projectPath : '/p.xcodeproj' ,
68- scheme : 'App' ,
69- platform : 'macOS'
70- } as any , mock ) ;
72+ let capturedCommand : string [ ] = [ ] ;
73+ const mockExecutor = async ( command : string [ ] ) => {
74+ capturedCommand = command ;
75+ return { success : true , output : 'clean success' } ;
76+ } ;
77+
78+ const result = await cleanLogic (
79+ {
80+ projectPath : '/p.xcodeproj' ,
81+ scheme : 'App' ,
82+ platform : 'macOS' ,
83+ } as any ,
84+ mockExecutor ,
85+ ) ;
7186 expect ( result . isError ) . not . toBe ( true ) ;
72-
73- // Check that the executor was called with macOS platform arguments
74- expect ( mock ) . toHaveBeenCalled ( ) ;
75- const commandArgs = mock . mock . calls [ 0 ] [ 0 ] ;
76- expect ( commandArgs ) . toContain ( '-destination' ) ;
77- expect ( commandArgs ) . toContain ( 'platform=macOS' ) ;
87+
88+ // Check that the command contains macOS platform destination
89+ const commandStr = capturedCommand . join ( ' ' ) ;
90+ expect ( commandStr ) . toContain ( '-destination' ) ;
91+ expect ( commandStr ) . toContain ( 'platform=macOS' ) ;
7892 } ) ;
7993
80- it ( 'accepts iOS Simulator platform parameter' , async ( ) => {
81- const mock = createMockExecutor ( { success : true , output : 'clean success' } ) ;
82- const result = await cleanLogic ( {
83- projectPath : '/p.xcodeproj' ,
84- scheme : 'App' ,
85- platform : 'iOS Simulator'
86- } as any , mock ) ;
94+ it ( 'accepts iOS Simulator platform parameter (maps to iOS for clean)' , async ( ) => {
95+ let capturedCommand : string [ ] = [ ] ;
96+ const mockExecutor = async ( command : string [ ] ) => {
97+ capturedCommand = command ;
98+ return { success : true , output : 'clean success' } ;
99+ } ;
100+
101+ const result = await cleanLogic (
102+ {
103+ projectPath : '/p.xcodeproj' ,
104+ scheme : 'App' ,
105+ platform : 'iOS Simulator' ,
106+ } as any ,
107+ mockExecutor ,
108+ ) ;
87109 expect ( result . isError ) . not . toBe ( true ) ;
88-
89- // Check that the executor was called with iOS Simulator platform arguments
90- expect ( mock ) . toHaveBeenCalled ( ) ;
91- const commandArgs = mock . mock . calls [ 0 ] [ 0 ] ;
92- expect ( commandArgs ) . toContain ( '-destination' ) ;
93- expect ( commandArgs ) . toContain ( 'platform=iOS Simulator' ) ;
110+
111+ // For clean operations, iOS Simulator should be mapped to iOS platform
112+ const commandStr = capturedCommand . join ( ' ' ) ;
113+ expect ( commandStr ) . toContain ( '-destination' ) ;
114+ expect ( commandStr ) . toContain ( 'platform=iOS' ) ;
94115 } ) ;
95116
96117 it ( 'handler validation: rejects invalid platform values' , async ( ) => {
97118 const result = await ( tool as any ) . handler ( {
98119 projectPath : '/p.xcodeproj' ,
99120 scheme : 'App' ,
100- platform : 'InvalidPlatform'
121+ platform : 'InvalidPlatform' ,
101122 } ) ;
102123 expect ( result . isError ) . toBe ( true ) ;
103124 const text = String ( result . content ?. [ 1 ] ?. text ?? result . content ?. [ 0 ] ?. text ?? '' ) ;
0 commit comments