11import { describe , expect , it , vi } from 'vitest' ;
22
3- import { makeDiscoverableExo } from './discoverable.ts' ;
3+ import { GET_DESCRIPTION , makeDiscoverableExo } from './discoverable.ts' ;
44import type { MethodSchema } from './schema.ts' ;
55
66const makeExoMock = vi . hoisted ( ( ) =>
@@ -56,16 +56,16 @@ describe('makeDiscoverableExo', () => {
5656 expect ( exo ) . toBeDefined ( ) ;
5757 expect ( exo . greet ) . toBeDefined ( ) ;
5858 expect ( exo . add ) . toBeDefined ( ) ;
59- expect ( exo . describe ) . toBeDefined ( ) ;
59+ expect ( exo [ GET_DESCRIPTION ] ) . toBeDefined ( ) ;
6060 } ) ;
6161
62- it ( 'returns full schema when describe is called' , ( ) => {
62+ it ( 'returns full schema when __getDescription__ is called' , ( ) => {
6363 const methods = { greet : ( name : string ) => `Hello, ${ name } !` } ;
6464 const schema = { greet : greetSchema } ;
6565
6666 const exo = makeDiscoverableExo ( 'TestExo' , methods , schema ) ;
6767
68- expect ( exo . describe ( ) ) . toStrictEqual ( schema ) ;
68+ expect ( exo [ GET_DESCRIPTION ] ( ) ) . toStrictEqual ( schema ) ;
6969 } ) ;
7070
7171 it ( 'preserves method functionality' , ( ) => {
@@ -94,7 +94,7 @@ describe('makeDiscoverableExo', () => {
9494 const exo = makeDiscoverableExo ( 'TestExo' , methods , schema ) ;
9595
9696 expect ( exo . getValue ( ) ) . toBe ( 42 ) ;
97- expect ( exo . describe ( ) ) . toStrictEqual ( {
97+ expect ( exo [ GET_DESCRIPTION ] ( ) ) . toStrictEqual ( {
9898 getValue : schema . getValue ,
9999 } ) ;
100100 } ) ;
@@ -117,18 +117,18 @@ describe('makeDiscoverableExo', () => {
117117
118118 exo . doSomething ( ) ;
119119 expect ( called ) . toBe ( true ) ;
120- expect ( exo . describe ( ) ) . toStrictEqual ( {
120+ expect ( exo [ GET_DESCRIPTION ] ( ) ) . toStrictEqual ( {
121121 doSomething : schema . doSomething ,
122122 } ) ;
123123 } ) ;
124124
125- it ( 'throws if describe is already a method' , ( ) => {
125+ it ( 'throws if __getDescription__ is already a method' , ( ) => {
126126 const methods = {
127- describe : ( ) => 'original describe' ,
127+ [ GET_DESCRIPTION ] : ( ) => 'original describe' ,
128128 greet : ( name : string ) => `Hello, ${ name } !` ,
129129 } ;
130130 const schema : Record < keyof typeof methods , MethodSchema > = {
131- describe : {
131+ [ GET_DESCRIPTION ] : {
132132 description : 'Original describe method' ,
133133 args : { } ,
134134 returns : { type : 'string' , description : 'Original description' } ,
@@ -138,7 +138,9 @@ describe('makeDiscoverableExo', () => {
138138
139139 expect ( ( ) => {
140140 makeDiscoverableExo ( 'TestExo' , methods , schema ) ;
141- } ) . toThrow ( 'The `describe` method name is reserved for discoverable exos.' ) ;
141+ } ) . toThrow (
142+ `The \`${ GET_DESCRIPTION } \` method name is reserved for discoverable exos.` ,
143+ ) ;
142144 } ) ;
143145
144146 it ( 're-throws errors from makeExo that are not about describe key' , ( ) => {
0 commit comments