Created
November 15, 2014 16:42
-
-
Save sebastiangeiger/32078e8d1f1ed44381e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>coderetreat Test Suite</title> | |
<script src="http://code.jquery.com/jquery-latest.js"></script> | |
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/qunit/1.14.0/qunit.css" type="text/css" media="screen"/> | |
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/qunit/1.14.0/qunit.js"></script> | |
<!-- Your project file goes here --> | |
<script type="text/javascript" src="coderetreat.js"></script> | |
<!-- Your tests file goes here --> | |
<script type="text/javascript" src="coderetreatTest.js"></script> | |
</head> | |
<body> | |
<h1 id="qunit-header">coderetreat</h1> | |
<h2 id="qunit-banner"></h2> | |
<div id="qunit-testrunner-toolbar"></div> | |
<h2 id="qunit-userAgent"></h2> | |
<ol id="qunit-tests"></ol> | |
<div id="qunit-fixture">test markup, will be hidden</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Cell(_coords){ | |
this._alive = true | |
this.isAlive = function(){ | |
return this._alive; | |
} | |
this.kill = function () { | |
this._alive = false; | |
} | |
this.coords = function () { | |
return _coords; | |
} | |
} | |
function CoordinatesNotSetError(){ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test("Cell is initially alive", function () { | |
equal(new Cell().isAlive(), true) ; | |
}); | |
test("I can kill cells", function(){ | |
var cell = new Cell(); | |
cell.kill(); | |
equal(cell.isAlive(), false); | |
}); | |
test('a cell has coordinates', function () { | |
var cell = new Cell([1,2]); | |
deepEqual(cell.coords(), [1,2]); | |
}); | |
test('a cell has coordinates - part 2', function () { | |
var cell = new Cell([2,4]); | |
deepEqual(cell.coords(), [2,4]); | |
}); | |
test('a cell has coordinates - part 2', function () { | |
var cell = new Cell(); | |
throws(cell.coords, new CoordinatesNotSetError()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment