@@ -371,9 +371,12 @@ describe('.createApiServer', () => {
371371 let response ;
372372 let db ;
373373 let games ;
374+ const warnMsg =
375+ 'This endpoint /rename is deprecated. Please use /update instead.' ;
374376
375377 beforeEach ( ( ) => {
376378 games = [ ProcessGameConfig ( { name : 'foo' } ) ] ;
379+ console . warn = jest . fn ( ) ;
377380 } ) ;
378381
379382 describe ( 'for an unprotected lobby' , ( ) => {
@@ -391,6 +394,7 @@ describe('.createApiServer', () => {
391394 . post ( '/games/foo/1/rename' )
392395 . send ( 'playerID=0&playerName=alice&newName=ali' ) ;
393396 expect ( response . status ) . toEqual ( 404 ) ;
397+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
394398 } ) ;
395399 } ) ;
396400
@@ -430,11 +434,13 @@ describe('.createApiServer', () => {
430434 expect ( response . text ) . toEqual (
431435 'newName must be a string, got number'
432436 ) ;
437+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
433438 } ) ;
434439 } ) ;
435440
436441 test ( 'is successful' , async ( ) => {
437442 expect ( response . status ) . toEqual ( 200 ) ;
443+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
438444 } ) ;
439445
440446 test ( 'updates the players' , async ( ) => {
@@ -448,6 +454,7 @@ describe('.createApiServer', () => {
448454 } ) ,
449455 } )
450456 ) ;
457+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
451458 } ) ;
452459 } ) ;
453460
@@ -458,6 +465,7 @@ describe('.createApiServer', () => {
458465 . post ( '/games/foo/1/rename' )
459466 . send ( 'playerID=2&credentials=SECRET1&newName=joe' ) ;
460467 expect ( response . status ) . toEqual ( 404 ) ;
468+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
461469 } ) ;
462470 } ) ;
463471
@@ -468,6 +476,7 @@ describe('.createApiServer', () => {
468476 . post ( '/games/foo/1/rename' )
469477 . send ( 'playerID=0&credentials=SECRET2&newName=mike' ) ;
470478 expect ( response . status ) . toEqual ( 403 ) ;
479+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
471480 } ) ;
472481 } ) ;
473482 describe ( 'when playerID is omitted' , ( ) => {
@@ -480,7 +489,9 @@ describe('.createApiServer', () => {
480489
481490 test ( 'throws error 403' , async ( ) => {
482491 expect ( response . status ) . toEqual ( 403 ) ;
492+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
483493 } ) ;
494+
484495 describe ( 'when newName is omitted' , ( ) => {
485496 beforeEach ( async ( ) => {
486497 const app = createApiServer ( { db, games } ) ;
@@ -491,6 +502,7 @@ describe('.createApiServer', () => {
491502
492503 test ( 'throws error 403' , async ( ) => {
493504 expect ( response . status ) . toEqual ( 403 ) ;
505+ expect ( console . warn ) . toBeCalledWith ( warnMsg ) ;
494506 } ) ;
495507 } ) ;
496508 } ) ;
0 commit comments