@@ -4,14 +4,16 @@ import { tournament } from "./tournament.js";
44
55function makeCtx ( withRunner : boolean ) : {
66 ctx : CommandContext ;
7- calls : { task : string ; count : number } [ ] ;
7+ calls : { task : string ; count : number ; models ?: string [ ] } [ ] ;
88 emits : string [ ] ;
99} {
10- const calls : { task : string ; count : number } [ ] = [ ] ;
10+ const calls : { task : string ; count : number ; models ?: string [ ] } [ ] = [ ] ;
1111 const emits : string [ ] = [ ] ;
1212 const ctx = {
1313 emit : ( t : string ) => emits . push ( t ) ,
14- runTournament : withRunner ? ( task : string , count : number ) => calls . push ( { task, count } ) : undefined ,
14+ runTournament : withRunner
15+ ? ( task : string , opts : { count : number ; models ?: string [ ] } ) => calls . push ( { task, ...opts } )
16+ : undefined ,
1517 } as unknown as CommandContext ;
1618 return { ctx, calls, emits } ;
1719}
@@ -20,20 +22,45 @@ describe("/tournament", () => {
2022 it ( "defaults to 3 contestants when no count is given" , ( ) => {
2123 const { ctx, calls } = makeCtx ( true ) ;
2224 tournament . handler ( "add pagination to the list" , ctx ) ;
23- expect ( calls ) . toEqual ( [ { task : "add pagination to the list" , count : 3 } ] ) ;
25+ expect ( calls ) . toEqual ( [ { task : "add pagination to the list" , count : 3 , models : undefined } ] ) ;
2426 } ) ;
2527
2628 it ( "parses and clamps a leading count to 2..5" , ( ) => {
2729 const { ctx, calls } = makeCtx ( true ) ;
2830 tournament . handler ( "9 refactor the parser" , ctx ) ;
29- expect ( calls [ 0 ] ) . toEqual ( { task : "refactor the parser" , count : 5 } ) ;
31+ expect ( calls [ 0 ] ) . toMatchObject ( { task : "refactor the parser" , count : 5 } ) ;
3032 } ) ;
3133
3234 it ( "treats a number-only arg as the task, not a count" , ( ) => {
3335 const { ctx, calls } = makeCtx ( true ) ;
3436 tournament . handler ( "42" , ctx ) ;
35- // "42" alone has no task after it, so it stays the task with default count.
36- expect ( calls [ 0 ] ) . toEqual ( { task : "42" , count : 3 } ) ;
37+ expect ( calls [ 0 ] ) . toMatchObject ( { task : "42" , count : 3 } ) ;
38+ } ) ;
39+
40+ it ( "parses --models into one contestant per model" , ( ) => {
41+ const { ctx, calls } = makeCtx ( true ) ;
42+ tournament . handler ( "--models opus,sonnet,haiku fix the parser" , ctx ) ;
43+ expect ( calls [ 0 ] ) . toEqual ( { task : "fix the parser" , count : 3 , models : [ "opus" , "sonnet" , "haiku" ] } ) ;
44+ } ) ;
45+
46+ it ( "supports --models=a,b syntax and ignores a leading digit as task text" , ( ) => {
47+ const { ctx, calls } = makeCtx ( true ) ;
48+ tournament . handler ( "--models=a,b 2fa support" , ctx ) ;
49+ expect ( calls [ 0 ] ) . toEqual ( { task : "2fa support" , count : 2 , models : [ "a" , "b" ] } ) ;
50+ } ) ;
51+
52+ it ( "rejects a single-model list" , ( ) => {
53+ const { ctx, calls, emits } = makeCtx ( true ) ;
54+ tournament . handler ( "--models solo do a thing" , ctx ) ;
55+ expect ( calls ) . toHaveLength ( 0 ) ;
56+ expect ( emits [ 0 ] ) . toMatch ( / a t l e a s t 2 / ) ;
57+ } ) ;
58+
59+ it ( "caps the model list at 5" , ( ) => {
60+ const { ctx, calls } = makeCtx ( true ) ;
61+ tournament . handler ( "--models a,b,c,d,e,f,g build" , ctx ) ;
62+ expect ( calls [ 0 ] . models ) . toHaveLength ( 5 ) ;
63+ expect ( calls [ 0 ] . count ) . toBe ( 5 ) ;
3764 } ) ;
3865
3966 it ( "shows usage when given no task" , ( ) => {
0 commit comments