-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from matthojo/tests
Added Log, Loop and Mediator tests and other test foundations
- Loading branch information
Showing
7 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("City", function() { | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.City).to.exist; | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("DOMEvents", function() { | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.DOMEvents).to.exist; | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe("Geo", function() { | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.Geo).to.exist; | ||
}); | ||
|
||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe("Log", function() { | ||
|
||
var spy; | ||
|
||
before(function(){ | ||
spy = sinon.spy(VIZI, "Log"); | ||
}); | ||
|
||
afterEach(function(){ | ||
spy.reset(); // reset spy on every test, otherwise call information gets stacked. | ||
}); | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.Log).to.exist; | ||
}); | ||
|
||
it("runs `Log` function", function() { | ||
|
||
VIZI.Log("arg1", "arg2", "arg3"); | ||
|
||
assert.equal(spy.called, true); | ||
}); | ||
|
||
it("accepts and sets arguments correctly", function() { | ||
|
||
VIZI.Log("arg1", 2, {"arg": 3}); | ||
|
||
assert.deepEqual(spy.args[0], ["arg1", 2, {"arg": 3}]); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
describe("Loop", function() { | ||
var loop; | ||
|
||
before(function () { | ||
loop = new VIZI.Loop(); | ||
}); | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.Loop).to.exist; | ||
}); | ||
|
||
it("has a 'start' function", function() { | ||
expect(loop).to.have.property("start"); | ||
}); | ||
|
||
it("has a 'stop' function", function() { | ||
expect(loop).to.have.property("stop"); | ||
}); | ||
|
||
it("has a 'tick' function", function() { | ||
expect(loop).to.have.property("tick"); | ||
}); | ||
|
||
it("starts loop", function() { | ||
var spy = new sinon.spy(loop, "start"); | ||
loop.stop(); // Stop default loop | ||
loop.start(); | ||
|
||
assert.equal(spy.called, true); | ||
assert.equal(loop.stopLoop, false); | ||
|
||
loop.stop(); | ||
}); | ||
|
||
it("calls `tick()` on start", function() { | ||
var spy = new sinon.spy(loop, "tick"); | ||
loop.start(); | ||
loop.stop(); | ||
|
||
assert.equal(spy.called, true); | ||
}); | ||
|
||
it("stops loop", function() { | ||
var spy = new sinon.spy(loop, "stop"); | ||
loop.start(); | ||
loop.stop(); | ||
|
||
assert.equal(spy.called, true); | ||
assert.equal(loop.stopLoop, true); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe("Mediator", function() { | ||
|
||
it("exists in `VIZI`", function() { | ||
expect(VIZI.Mediator).to.exist; | ||
}); | ||
|
||
it("has a 'publish' function", function() { | ||
expect(VIZI.Mediator).to.have.property("publish"); | ||
}); | ||
|
||
it("has a 'subscribe' function", function() { | ||
expect(VIZI.Mediator).to.have.property("subscribe"); | ||
}); | ||
|
||
it("subscribes and publishes to a topic", function() { | ||
var spy = sinon.spy(); | ||
var message = "this is a message"; | ||
|
||
VIZI.Mediator.subscribe("test_topic", spy); | ||
VIZI.Mediator.publish("test_topic", message); | ||
|
||
assert.equal(message, spy.args[0][0]); | ||
}); | ||
}); |