11import { describe , it , expect } from 'vitest' ;
2+ import { z } from 'zod' ;
23import { createMockExecutor } from '../../../utils/command.js' ;
34import plugin , { show_build_set_projLogic } from '../show_build_set_proj.ts' ;
45
@@ -18,41 +19,26 @@ describe('show_build_set_proj plugin', () => {
1819 expect ( typeof plugin . handler ) . toBe ( 'function' ) ;
1920 } ) ;
2021
21- it ( 'should validate schema with valid inputs' , ( ) => {
22- expect (
23- plugin . schema . safeParse ( { projectPath : '/path/to/MyProject.xcodeproj' , scheme : 'MyScheme' } )
24- . success ,
25- ) . toBe ( true ) ;
26- expect (
27- plugin . schema . safeParse ( { projectPath : '/Users/dev/App.xcodeproj' , scheme : 'AppScheme' } )
28- . success ,
29- ) . toBe ( true ) ;
30- } ) ;
31-
32- it ( 'should validate schema with invalid inputs' , ( ) => {
33- expect ( plugin . schema . safeParse ( { } ) . success ) . toBe ( false ) ;
34- expect ( plugin . schema . safeParse ( { projectPath : '/path/to/project.xcodeproj' } ) . success ) . toBe (
35- false ,
36- ) ;
37- expect ( plugin . schema . safeParse ( { scheme : 'MyScheme' } ) . success ) . toBe ( false ) ;
38- expect ( plugin . schema . safeParse ( { projectPath : 123 , scheme : 'MyScheme' } ) . success ) . toBe ( false ) ;
39- expect (
40- plugin . schema . safeParse ( { projectPath : '/path/to/project.xcodeproj' , scheme : 123 } ) . success ,
41- ) . toBe ( false ) ;
22+ it ( 'should have schema object' , ( ) => {
23+ expect ( plugin . schema ) . toBeDefined ( ) ;
24+ expect ( typeof plugin . schema ) . toBe ( 'object' ) ;
4225 } ) ;
4326 } ) ;
4427
4528 describe ( 'Handler Behavior (Complete Literal Returns)' , ( ) => {
4629 it ( 'should handle schema validation error when projectPath is null' , async ( ) => {
47- // Schema validation will throw before reaching validateRequiredParam
48- await expect ( plugin . handler ( { projectPath : null , scheme : 'MyScheme' } ) ) . rejects . toThrow ( ) ;
30+ const result = await plugin . handler ( { projectPath : null , scheme : 'MyScheme' } ) ;
31+ expect ( result . isError ) . toBe ( true ) ;
32+ expect ( result . content [ 0 ] . text ) . toContain ( "Required parameter 'projectPath' is missing" ) ;
4933 } ) ;
5034
5135 it ( 'should handle schema validation error when scheme is null' , async ( ) => {
52- // Schema validation will throw before reaching validateRequiredParam
53- await expect (
54- plugin . handler ( { projectPath : '/path/to/MyProject.xcodeproj' , scheme : null } ) ,
55- ) . rejects . toThrow ( ) ;
36+ const result = await plugin . handler ( {
37+ projectPath : '/path/to/MyProject.xcodeproj' ,
38+ scheme : null ,
39+ } ) ;
40+ expect ( result . isError ) . toBe ( true ) ;
41+ expect ( result . content [ 0 ] . text ) . toContain ( "Required parameter 'scheme' is missing" ) ;
5642 } ) ;
5743
5844 it ( 'should return success with build settings' , async ( ) => {
@@ -77,7 +63,7 @@ describe('show_build_set_proj plugin', () => {
7763 return mockExecutor ( ...args ) ;
7864 } ;
7965
80- const result = await plugin . handler (
66+ const result = await show_build_set_projLogic (
8167 {
8268 projectPath : '/path/to/MyProject.xcodeproj' ,
8369 scheme : 'MyScheme' ,
@@ -129,7 +115,7 @@ describe('show_build_set_proj plugin', () => {
129115 process : { pid : 12345 } ,
130116 } ) ;
131117
132- const result = await plugin . handler (
118+ const result = await show_build_set_projLogic (
133119 {
134120 projectPath : '/path/to/MyProject.xcodeproj' ,
135121 scheme : 'InvalidScheme' ,
@@ -148,7 +134,7 @@ describe('show_build_set_proj plugin', () => {
148134 throw new Error ( 'Command execution failed' ) ;
149135 } ;
150136
151- const result = await plugin . handler (
137+ const result = await show_build_set_projLogic (
152138 {
153139 projectPath : '/path/to/MyProject.xcodeproj' ,
154140 scheme : 'MyScheme' ,
0 commit comments