Tests for Cylon#api
This commit is contained in:
parent
da5cb27c21
commit
1778312e6c
|
@ -85,6 +85,9 @@
|
|||
};
|
||||
|
||||
Master.prototype.api = function(opts) {
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
api_config.host = opts.host || "127.0.0.1";
|
||||
api_config.port = opts.port || "3000";
|
||||
return api_config;
|
||||
|
|
|
@ -86,7 +86,7 @@ class Cylon
|
|||
# port - port API should listen for requests on
|
||||
#
|
||||
# Returns the API configuration
|
||||
api: (opts) ->
|
||||
api: (opts = {}) ->
|
||||
api_config.host = opts.host || "127.0.0.1"
|
||||
api_config.port = opts.port || "3000"
|
||||
api_config
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
Cylon = source("cylon");
|
||||
|
||||
describe("Cylon", function() {
|
||||
return it("should create a robot", function() {
|
||||
it("should create a robot", function() {
|
||||
var robot;
|
||||
assert(__indexOf.call(Object.keys(Cylon), 'robot') >= 0);
|
||||
robot = Cylon.robot({
|
||||
|
@ -14,6 +14,26 @@
|
|||
});
|
||||
return robot.name.should.be.eql('caprica six');
|
||||
});
|
||||
return describe('#api', function() {
|
||||
describe('without arguments', function() {
|
||||
return it("returns the current API configuration", function() {
|
||||
var api_config;
|
||||
api_config = Cylon.api();
|
||||
assert(__indexOf.call(Object.keys(api_config), 'host') >= 0);
|
||||
return assert(__indexOf.call(Object.keys(api_config), 'port') >= 0);
|
||||
});
|
||||
});
|
||||
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'
|
||||
});
|
||||
api_config.host.should.be.eql("0.0.0.0");
|
||||
return api_config.port.should.be.eql("8888");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
|
|
@ -7,3 +7,16 @@ describe "Cylon", ->
|
|||
assert 'robot' in Object.keys(Cylon)
|
||||
robot = Cylon.robot(name: 'caprica six')
|
||||
robot.name.should.be.eql 'caprica six'
|
||||
|
||||
describe '#api', ->
|
||||
describe 'without arguments', ->
|
||||
it "returns the current API configuration", ->
|
||||
api_config = Cylon.api()
|
||||
assert 'host' in Object.keys(api_config)
|
||||
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"
|
||||
|
|
Loading…
Reference in New Issue