{"size": 1300, "ext": "js", "max_stars_repo_path": "integrate/stepped-and-separated/tic-tac-toe-separated/logic/play.js", "max_stars_repo_name": "gelilaa/state", "max_stars_repo_stars_event_min_datetime": "2020-09-07T08:07:47.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-07T08:07:47.000Z", "max_issues_repo_path": "integrate/stepped-and-separated/tic-tac-toe-separated/logic/play.js", "max_issues_repo_name": "oguzkarademir/state", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "integrate/stepped-and-separated/tic-tac-toe-separated/logic/play.js", "max_forks_repo_name": "oguzkarademir/state", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 36.1111111111, "max_line_length": 89, "alphanum_fraction": 0.6161538462}
function play(oldPlayer, oldValue) {
  const nextPlay = {};
  if (oldValue !== null) {
    nextPlay.nextPlayer = oldPlayer;
    nextPlay.squareValue = oldValue;
  } else {
    nextPlay.nextPlayer = oldPlayer === 'X'
      ? 'O'
      : 'X';
    nextPlay.squareValue = oldPlayer;
  }
  return nextPlay;
}

const playTests = [
  { name: 'Test 1', args: ['X', null], expected: { nextPlayer: 'O', squareValue: 'X' } },
  { name: 'Test 2', args: ['O', null], expected: { nextPlayer: 'X', squareValue: 'O' } },
  { name: 'Test 3', args: ['X', 'X'], expected: { nextPlayer: 'X', squareValue: 'X' } },
  { name: 'Test 4', args: ['O', 'X'], expected: { nextPlayer: 'O', squareValue: 'X' } },
  { name: 'Test 5', args: ['X', 'O'], expected: { nextPlayer: 'X', squareValue: 'O' } },
  { name: 'Test 6', args: ['O', 'O'], expected: { nextPlayer: 'O', squareValue: 'O' } },
];

console.log('-- testing: play --');
debugger;
for (let test of playTests) {
  const expected = test.expected;
  const actual = play(...test.args);
  const nextPlayerPasses = actual.nextPlayer === expected.nextPlayer
  const squareValuePasses = actual.squareValue === expected.squareValue;
  const passing = nextPlayerPasses && squareValuePasses;
  console.assert(passing, test.name);
  test.actual = actual;
};
console.log(playTests);
