Skip to content

Instantly share code, notes, and snippets.

@timkellogg
Last active September 16, 2015 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timkellogg/ea3b3db7711e4e28e6dc to your computer and use it in GitHub Desktop.
Save timkellogg/ea3b3db7711e4e28e6dc to your computer and use it in GitHub Desktop.
function Player (mark) {
this.mark = mark
};
function Space (x,y) {
this.coordinates = [x,y]
this.markedBy = undefined
};
Space.prototype.marked = function(player) {
this.markedBy = player;
};
function Board () {
spaces = [];
for (var x = 0; x < 2; x ++) {
for (var y = 0; y < 2; y++ ) {
spaces.push(new Space(x,y) );
};
};
console.log(spaces);
};
SPECS
describe('Player', function() {
it("returns the player's mark", function() {
var testPlayer = new Player("X");
expect(testPlayer.mark).to.equal("X");
});
});
describe("Space", function() {
it("returns the coordinates of the space", function() {
var testSpace = new Space(1,2);
expect(testSpace.coordinates[0]).to.equal(1);
expect(testSpace.coordinates[1]).to.equal(2);
});
it("returns the player it's filled with when marked", function() {
var testPlayer = new Player("X");
var testSpace = new Space(1,2);
testSpace.marked(testPlayer);
expect(testSpace.markedBy).to.equal(testPlayer);
});
});
describe("Board", function() {
it("creates a board with 3 rows of spaces", function() {
var testBoard = new Board();
});
});
// describe(Board) do
// it("creates 9 spaces when it is initialized") do # You write the rest!
// end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment