describe ("Test Game", function() {
  describe ("Test visualAfterGameOver function", function() {
    var toggleDisplayedButton;
    var restartGame;
    var unbind;
    var click;

    beforeEach (function() {
      toggleDisplayedButton = spyOn(UI, "toggleDisplayedButton");
      restartGame = spyOn(Game, "restartGame");
      unbind = spyOn($.fn, "unbind");
      click = spyOnEvent('tr td', 'click');
    });

    it ("Test call function after game over", function() {
      Game.visualAfterGameOver();
      expect(unbind).toHaveBeenCalled();
      expect(click).not.toHaveBeenTriggered();
      expect(toggleDisplayedButton).toHaveBeenCalled();
      expect(restartGame).toHaveBeenCalled();
    });
  });

  describe ("Test winner function", function() {
    var thePlayer;

    it ("Player1 if current player is 'X'", function() {
      currentPlayer = "X"
      thePlayer = Game.winner(currentPlayer);
      expect(thePlayer).toBe("Player");
    });

    it ("Player1 if current player is 'X'", function() {
      currentPlayer = "O"
      thePlayer = Game.winner(currentPlayer);
      expect(thePlayer).toBe("Computer");
    });
  });

  describe ("Teste firstMove function", function() {
    var input;
    var visualAfterChoice;

    beforeEach(function() {
      Game.currentPlayer = "";
      visualAfterChoice = spyOn(Game, "visualAfterChoice");
    })

    it ("If input is null return true", function() {
      var askFirstMove = spyOn(UI, "askFirstMove").and.returnValue(null);
      input = askFirstMove;
      expect(Game.firstMove()).toBeTruthy();
    })

    it ("If input is '' return true", function() {
      var askFirstMove = spyOn(UI, "askFirstMove").and.returnValue("");
      input = askFirstMove;
      expect(Game.firstMove()).toBeTruthy();
    })

    it ("If input is 'y', will call visualAfterChoice() and will change current player", function() {
      var askFirstMove = spyOn(UI, "askFirstMove").and.returnValue("y");
      input = askFirstMove;
      Game.firstMove();
      expect(visualAfterChoice).toHaveBeenCalled();
      expect(Game.goFirst).toBe("y");
    })

    it ("If input is 'n', will call visualAfterChoice() and will change current player", function() {
      var askFirstMove = spyOn(UI, "askFirstMove").and.returnValue("n");
      input = askFirstMove;
      Game.firstMove();
      expect(visualAfterChoice).toHaveBeenCalled();
      expect(Game.goFirst).toBe("n");
    })
  });

  describe ("Test nextTurn function", function() {
    var winMessage;
    var tieMessage;
    var visualAfterGameOver;

    beforeEach (function() {
      winMessage = spyOn(UI, "winMessage");
      tieMessage = spyOn(UI, "tieMessage");
      visualAfterGameOver = spyOn(Game, "visualAfterGameOver");
    });

    describe ("Message pops up when GameOver", function() {
      it ("Pops up for win and click event doesn't work,if the Game win.", function() {
        GameBoard.spots = ["X", "X", "X", "O", 5, "O", 7, 8, 9];
        Game.nextTurn();
        expect(winMessage).toHaveBeenCalled();
        expect(visualAfterGameOver).toHaveBeenCalled();
      });

      it ("Pops up for tie and click event doesn't work,if the Game tie.", function() {
        GameBoard.spots = ["X", "O", "X", "O", "X", "X", "O", "X", "O"];
        Game.nextTurn();
        expect(tieMessage).toHaveBeenCalled();
        expect(visualAfterGameOver).toHaveBeenCalled();
      });

      it ("Not Pops up any message and click event works,if the Game is not won or tied.", function() {
        GameBoard.spots = ["X", 2, 3, 4, 5, 6, 7, 8, 9];
        Game.nextTurn();
        expect(winMessage).not.toHaveBeenCalled();
        expect(tieMessage).not.toHaveBeenCalled();
        expect(visualAfterGameOver).not.toHaveBeenCalled();
      });
    });
  });
});

@@ -3766,12 +3766,1349 @@
 ;%0A  %7D);%0A
-%7D);
+%0A  describe (%22Test humanPlay function%22, function() %7B%0A    var showHumanMessage;%0A    var hideHumanMessage;%0A    var click;%0A%0A    beforeEach(function() %7B%0A      GameBoard.spots = %5B1, 2, 3, 4, 5, 6, 7, 8, 9%5D;%0A      showHumanMessage = spyOn(UI, %22showHumanMessage%22);%0A      hideHumanMessage = spyOn(UI, %22hideHumanMessage%22);%0A      click = spyOnEvent('tr td', 'click');%0A      setFixtures(' %3Ch1 id = %22Human%22%3EClick a spot you want.%3C/h1%3E %5C%0A                    %3Cbutton type=%22button%22 class = %22btn-start%22%3EStart Game%3C/button%3E %5C%0A                    %3Cbutton type=%22button%22 class = %22btn-new%22%3ENew Game%3C/button%3E %5C%0A                    %3Cbutton type=%22button%22 class = %22btn-restart%22%3ERestart Game%3C/button%3E %5C%0A                    %3Ctr%3E %5C%0A                      %3Ctd id = %220%22%3E%3C/td%3E %5C%0A                      %3Ctd id = %221%22%3EX%3C/td%3E %5C%0A                      %3Ctd id = %222%22%3E%3C/td%3E %5C%0A                    %3C/tr%3E ');%0A    %7D);%0A%0A    it (%22Shows message for human player after humanPlay running%22, function() %7B%0A      Game.humanPlay(Game.computerPlay);%0A      expect(showHumanMessage).toHaveBeenCalled();%0A      expect($(%22#jasmine-fixtures #Human%22)).toBeVisible();%0A    %7D);%0A%0A    it (%22After human choice a spot cant click%22, function() %7B%0A      Game.humanPlay(Game.computerPlay);%0A      $(%22#jasmine-fixtures #0%22).click();%0A      expect(click).not.toHaveBeenTriggered()%0A    %7D)%0A  %7D)%0A%7D);%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A
 %0A

Test humanplay() in Game