From d7b3e63afe8976343bf606691833bc25c0c739d5 Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Fri, 8 Nov 2013 14:43:05 -0700 Subject: [PATCH] Test for Cylon#robots --- test/dist/specs/cylon.spec.js | 34 +++++++++++++++++++++++--------- test/src/specs/cylon.spec.coffee | 15 ++++++++++---- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/test/dist/specs/cylon.spec.js b/test/dist/specs/cylon.spec.js index abddb54..2396938 100644 --- a/test/dist/specs/cylon.spec.js +++ b/test/dist/specs/cylon.spec.js @@ -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; }); }); }); diff --git a/test/src/specs/cylon.spec.coffee b/test/src/specs/cylon.spec.coffee index 6c697be..a9ca908 100644 --- a/test/src/specs/cylon.spec.coffee +++ b/test/src/specs/cylon.spec.coffee @@ -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