Permalink
Browse files

Linting.

  • Loading branch information...
1 parent b777bf0 commit 47b735ff61f4d4ca4b10681b0b4f144d8ff4690d @magnars committed May 14, 2012
View
@@ -9,8 +9,9 @@ module.exports = {
vars: true,
maxlen: 85,
sloppy: false,
+ regexp: true,
browser: true,
node: true,
- predef: [ "ZOMBIE", "buster", "$", "assert", "refute", "EventEmitter" ]
+ predef: [ "ZOMBIE", "buster", "$", "assert", "refute", "EventEmitter", "jQuery" ]
}
};
@@ -9,7 +9,9 @@ var ZOMBIE = this.ZOMBIE || {};
function renderBarricade(barricade) {
if (barricade > 0) {
- return "<li class='barricade'><p>Barricade: " + Math.floor(barricade) + "% integrity</p></li>";
+ return "<li class='barricade'><p>Barricade: " +
+ Math.floor(barricade) +
+ "% integrity</p></li>";
} else {
return "";
}
View
@@ -18,11 +18,11 @@ var ZOMBIE = this.ZOMBIE || {};
},
tick: function () {
- var inTransit;
+ var inTransit, roomIndex;
this.barricade = Math.max(0, this.barricade - this.zombies / 100);
- for (var roomIndex = this.rooms.length-2; roomIndex >= 0; roomIndex--) {
+ for (roomIndex = this.rooms.length - 2; roomIndex >= 0; roomIndex -= 1) {
var from = this.rooms[roomIndex];
- var to = this.rooms[roomIndex+1];
+ var to = this.rooms[roomIndex + 1];
inTransit = Math.min(2, from.zombies);
from.zombies -= inTransit;
to.zombiesEnter(inTransit);
@@ -60,7 +60,7 @@ var ZOMBIE = this.ZOMBIE || {};
};
ZOMBIE.rooms.trapdoor.zombiesEnter = function (inTransit) {
this.deadZombies += 1;
- this.zombies += inTransit-1;
+ this.zombies += inTransit - 1;
};
@@ -1,3 +1,5 @@
+/*global testHelper*/
+
(function () {
"use strict";
@@ -11,10 +11,11 @@ var testHelper = {};
var script = document.createElement("script");
var done = false;
- script.onload = script.onreadystatechange = function() {
+ script.onload = script.onreadystatechange = function () {
script.loaded = true;
- if ( !done && (!this.readyState ||
- this.readyState === "loaded" || this.readyState === "complete") ) {
+ if (!done && (!this.readyState ||
+ this.readyState === "loaded" ||
+ this.readyState === "complete")) {
done = true;
script.onload = script.onreadystatechange = null;
callback();
@@ -24,9 +25,11 @@ var testHelper = {};
script.loaded = false;
script.src = src;
- head.insertBefore( script, head.firstChild );
- setTimeout(function() {
- if(!script.loaded) throw new Error("SCRIPT NOT LOADED: " + script.src);
+ head.insertBefore(script, head.firstChild);
+ setTimeout(function () {
+ if (!script.loaded) {
+ throw new Error("SCRIPT NOT LOADED: " + script.src);
+ }
}, 300);
};
@@ -44,10 +44,10 @@ if (typeof require === "function" && typeof module !== "undefined") {
this.controller.init().then(spy);
refute.called(spy);
- this.subBuildRoom.callback.yield();
+ this.subBuildRoom.callback.invokeCallback();
refute.called(spy);
- this.subTick.callback.yield();
+ this.subTick.callback.invokeCallback();
assert.calledOnce(spy);
},
@@ -56,14 +56,18 @@ if (typeof require === "function" && typeof module !== "undefined") {
var listener = this.stub();
this.controller.on("change", listener);
- this.hub.subscribe.withArgs("/buildRoom").yields({ name: "Flamethrower Surprise" });
+ this.hub.subscribe.withArgs("/buildRoom").yields({
+ name: "Flamethrower Surprise"
+ });
this.controller.init();
assert.calledOnceWith(listener, this.building);
},
"should delegate events to building": function () {
- this.hub.subscribe.withArgs("/buildRoom").yields({ name: "Flamethrower Surprise" });
+ this.hub.subscribe.withArgs("/buildRoom").yields({
+ name: "Flamethrower Surprise"
+ });
this.controller.init();
assert.calledOnceWith(this.building.buildRoom, "Flamethrower Surprise");
@@ -33,13 +33,13 @@ if (typeof require === "function" && typeof module !== "undefined") {
},
"zombies destroy the barricade": function () {
- var building = Z.building.create({zombies:100, barricade: 100});
+ var building = Z.building.create({ zombies: 100, barricade: 100 });
building.tick();
- assert.equals(building.barricade, 100 - (100/100));
+ assert.equals(building.barricade, 100 - (100 / 100));
},
"zombies get through the barricade": function () {
- var building = Z.building.create({zombies:100, barricade:1 });
+ var building = Z.building.create({ zombies: 100, barricade: 1 });
building.tick();
building.tick();
assert.equals(building.barricade, 0);
@@ -152,7 +152,9 @@ if (typeof require === "function" && typeof module !== "undefined") {
},
"adds more rooms to building": function () {
- var building = Z.building.create({ rooms: [ Z.room.create({ name: "Trapdoor" }) ] });
+ var building = Z.building.create({
+ rooms: [ Z.room.create({ name: "Trapdoor" }) ]
+ });
building.buildRoom("Hiding spot");

0 comments on commit 47b735f

Please sign in to comment.