Skip to content

Commit ee007e6

Browse files
committed
update test harness and jshint checking on top of #27
1 parent 71ecf8e commit ee007e6

File tree

5 files changed

+13
-36
lines changed

5 files changed

+13
-36
lines changed

Gruntfile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ module.exports = function(grunt) {
1313
options: {
1414
browser: true,
1515
sub: true,
16-
globals: {
17-
}
16+
undef: true,
17+
unused: true
1818
},
19-
all: ['astar.js']
19+
all: ['astar.js', 'test/tests.js', 'demo/demo.js']
2020
}
2121
});
2222

astar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// http://eloquentjavascript.net/appendix2.html
77

88
(function(definition) {
9+
/* global module, define */
910
if(typeof module === 'object' && typeof module.exports === 'object') {
1011
module.exports = definition();
1112
} else if(typeof define === 'function' && define.amd) {

demo/demo.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,10 @@
33
44
Set up the demo page for the A* Search
55
*/
6-
7-
window.log = function(){
8-
if(this.console){
9-
console.log( Array.prototype.slice.call(arguments) );
10-
}
11-
};
6+
/* global Graph, astar, $ */
127

138
var WALL = 0,
14-
OPEN = 1;
15-
16-
var generateRandom = function (width, height, wallFrequency) {
17-
var nodes = [];
18-
for (var x = 0; x < width; x++) {
19-
var nodeRow = [],
20-
gridRow = [];
21-
22-
for (var y = 0; y < height; y++) {
23-
var isWall = Math.floor(Math.random()*(1/wallFrequency));
24-
if (isWall === 0) {
25-
nodeRow.push(WALL);
26-
}
27-
else {
28-
nodeRow.push(OPEN);
29-
}
30-
}
31-
nodes.push(nodeRow);
32-
}
33-
34-
return new Graph(nodes);
35-
};
9+
performance = window.performance;
3610

3711
$(function() {
3812

@@ -165,7 +139,6 @@ GraphSearch.prototype.cellClicked = function($end) {
165139
var end = this.nodeFromElement($end);
166140

167141
if($end.hasClass(css.wall) || $end.hasClass(css.start)) {
168-
log("clicked on wall or start...", $end);
169142
return;
170143
}
171144

@@ -196,7 +169,7 @@ GraphSearch.prototype.drawDebugInfo = function() {
196169
this.$cells.html(" ");
197170
var that = this;
198171
if(this.opts.debug) {
199-
that.$cells.each(function(i) {
172+
that.$cells.each(function() {
200173
var node = that.nodeFromElement($(this)),
201174
debug = false;
202175
if (node.visited) {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
},
1717
"homepage": "http://bgrins.github.io/javascript-astar",
1818
"devDependencies": {
19-
"grunt": "~0.4.2",
20-
"grunt-contrib-qunit": "~0.4.0",
21-
"grunt-contrib-jshint": "~0.8.0"
19+
"grunt": "~0.4.5",
20+
"grunt-contrib-qunit": "~0.5.0",
21+
"grunt-contrib-jshint": "~0.10.0"
2222
}
2323
}

test/tests.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
/* global Graph, astar, ok, test, equal */
3+
4+
25
test( "Sanity Checks", function() {
36
ok (typeof Graph !== "undefined", "Graph exists");
47
ok (typeof astar !== "undefined", "Astar exists");

0 commit comments

Comments
 (0)