From: Carl Worth <cworth@cworth.org>
Date: Mon, 1 Jun 2020 18:33:36 +0000 (-0700)
Subject: tictactoe: Track API change for the /move request: "square" -> "move"
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=9e5bf65868eaafcb11d09c0fee02e0d3d7c2121f;p=empires-server

tictactoe: Track API change for the /move request: "square" -> "move"

The API was recently changed to be more generic. We track that here by
looking for a .move property in the body object, instead of .square.

And we conform to that by sending events with data named "move" nota
"square" in the corresponding test cases.
---

diff --git a/test b/test
index 017f38e..0e42462 100755
--- a/test
+++ b/test
@@ -292,7 +292,7 @@ tictactoe_game_path=tictactoe/$tictactoe_game_id
 
 tictactoe_move()
 {
-    curl_post $tictactoe_game_path/move "{\"square\": $1}"
+    curl_post $tictactoe_game_path/move "{ \"move\": $1 }"
 }
 
 TEST_SUBSECTION "Tic Tac Toe /move"
@@ -308,4 +308,3 @@ test "$result" = "false"
 TEST_END
 
 TEST_REPORT
-
diff --git a/tictactoe.js b/tictactoe.js
index 89ad5d2..7d7450c 100644
--- a/tictactoe.js
+++ b/tictactoe.js
@@ -37,7 +37,7 @@ class TicTacToe extends Game {
 
 router.post('/move', (request, response) => {
   const game = request.game;
-  const square = request.body.square;
+  const square = request.body.move;
 
   const legal = game.add_move(square);