Test for Cylon#robots

This commit is contained in:
Andrew Stewart 2013-11-08 14:43:05 -07:00
parent 1778312e6c
commit d7b3e63afe
2 changed files with 36 additions and 13 deletions

View File

@ -1,10 +1,12 @@
(function() {
'use strict';
var Cylon,
var Cylon, Robot,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
Cylon = source("cylon");
Robot = source('robot');
describe("Cylon", function() {
it("should create a robot", function() {
var robot;
@ -14,7 +16,7 @@
});
return robot.name.should.be.eql('caprica six');
});
return describe('#api', function() {
describe('#api', function() {
describe('without arguments', function() {
return it("returns the current API configuration", function() {
var api_config;
@ -24,14 +26,28 @@
});
});
return describe('with a host and port', function() {
var api_config;
it('sets the API configuration to what was specified');
api_config = Cylon.api({
host: '0.0.0.0',
port: '8888'
return it('sets the API configuration to what was specified', function() {
var api_config;
api_config = Cylon.api({
host: '0.0.0.0',
port: '8888'
});
api_config.host.should.be.eql("0.0.0.0");
return api_config.port.should.be.eql("8888");
});
api_config.host.should.be.eql("0.0.0.0");
return api_config.port.should.be.eql("8888");
});
});
return describe("#robots", function() {
return it("returns an array of all robots", function() {
var robot, robots, _i, _len, _results;
robots = Cylon.robots();
assert(robots instanceof Array);
_results = [];
for (_i = 0, _len = robots.length; _i < _len; _i++) {
robot = robots[_i];
_results.push(assert(robot instanceof Robot));
}
return _results;
});
});
});

View File

@ -1,6 +1,7 @@
'use strict';
Cylon = source("cylon")
Robot = source('robot')
describe "Cylon", ->
it "should create a robot", ->
@ -16,7 +17,13 @@ describe "Cylon", ->
assert 'port' in Object.keys(api_config)
describe 'with a host and port', ->
it 'sets the API configuration to what was specified'
api_config = Cylon.api(host: '0.0.0.0', port: '8888')
api_config.host.should.be.eql "0.0.0.0"
api_config.port.should.be.eql "8888"
it 'sets the API configuration to what was specified', ->
api_config = Cylon.api(host: '0.0.0.0', port: '8888')
api_config.host.should.be.eql "0.0.0.0"
api_config.port.should.be.eql "8888"
describe "#robots", ->
it "returns an array of all robots", ->
robots = Cylon.robots()
assert robots instanceof Array
assert robot instanceof Robot for robot in robots