Skip to content
Browse files

Improve tests expecting objects/functions

  • Loading branch information...
1 parent 7cadbc4 commit 82d0604d134f57d14062b64ba0e22e3e2c187927 @fhd committed
Showing with 24 additions and 2 deletions.
  1. +1 −0 public/test/index.html
  2. +1 −1 public/test/sorting/display.js
  3. +21 −0 public/test/testUtils.js
  4. +1 −1 public/test/utilities.js
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)
},

0 comments on commit 82d0604

Please sign in to comment.
Something went wrong with that request. Please try again.