Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve tests expecting objects/functions

  • Loading branch information...
commit 82d0604d134f57d14062b64ba0e22e3e2c187927 1 parent 7cadbc4
@fhd authored
View
1  public/test/index.html
@@ -19,6 +19,7 @@
<script src="../js/dataStructures/linkedList.js"></script>
<script src="js/qunit.js"></script>
<script src="js/sinon-1.3.2.js"></script>
+ <script src="testUtils.js"></script>
<script src="utilities.js"></script>
<script src="sorting/display.js"></script>
<script src="sorting/worker.js"></script>
View
2  public/test/sorting/display.js
@@ -8,7 +8,7 @@ test("Array.shuffle", 1, function() {
});
test("init", 2, function() {
- var f = function() {};
+ var f = testUtils.uniqueFunction();
currentAlgorithmFile = "";
prettyPrint = sinon.spy();
View
21 public/test/testUtils.js
@@ -0,0 +1,21 @@
+var testUtils = {};
+
+(function(testUtils) {
+ var id = 0;
+
+ function uniqueId() {
+ return id++;
+ }
+
+ testUtils.uniqueObject = function() {
+ return {
+ __id: uniqueId()
+ };
+ };
+
+ testUtils.uniqueFunction = function() {
+ return function() {
+ var id = uniqueId();
+ };
+ }
+})(testUtils);
View
2  public/test/utilities.js
@@ -1,7 +1,7 @@
module("utilities");
test("createDrawFunction", 1, function() {
- var context = {},
+ var context = testUtils.uniqueObject(),
canvas = {
getContext: sinon.stub().returns(context)
},
Please sign in to comment.
Something went wrong with that request. Please try again.