@@ -170,7 +170,17 @@ describe('.createApiServer', () => {
170170 db = {
171171 set : async ( id , state ) => setSpy ( id , state ) ,
172172 } ;
173- games = [ Game ( { name : 'foo' } ) ] ;
173+ games = [
174+ Game ( {
175+ name : 'foo' ,
176+ setup : ( ctx , setupData ) =>
177+ setupData
178+ ? {
179+ colors : setupData . colors ,
180+ }
181+ : { } ,
182+ } ) ,
183+ ] ;
174184 } ) ;
175185
176186 describe ( 'for an unprotected lobby server' , ( ) => {
@@ -181,7 +191,15 @@ describe('.createApiServer', () => {
181191
182192 response = await request ( app . callback ( ) )
183193 . post ( '/games/foo/create' )
184- . send ( 'numPlayers=3' ) ;
194+ . send ( {
195+ numPlayers : 3 ,
196+ setupData : {
197+ colors : {
198+ '0' : 'green' ,
199+ '1' : 'red' ,
200+ } ,
201+ } ,
202+ } ) ;
185203 } ) ;
186204
187205 test ( 'is successful' , ( ) => {
@@ -199,6 +217,20 @@ describe('.createApiServer', () => {
199217 ) ;
200218 } ) ;
201219
220+ test ( 'passes arbitrary data to game setup' , ( ) => {
221+ expect ( setSpy ) . toHaveBeenCalledWith (
222+ expect . stringMatching ( 'foo:' ) ,
223+ expect . objectContaining ( {
224+ G : expect . objectContaining ( {
225+ colors : {
226+ '0' : 'green' ,
227+ '1' : 'red' ,
228+ } ,
229+ } ) ,
230+ } )
231+ ) ;
232+ } ) ;
233+
202234 test ( 'creates game metadata' , ( ) => {
203235 expect ( setSpy ) . toHaveBeenCalledWith (
204236 expect . stringMatching ( ':metadata' ) ,
0 commit comments