cylon/test/specs/port.spec.js

85 lines
2.4 KiB
JavaScript
Raw Normal View History

2013-10-25 05:25:42 +08:00
(function() {
'use strict';
2013-11-12 00:28:37 +08:00
source("port");
2013-10-25 05:25:42 +08:00
describe("Port", function() {
describe("remote TCP port", function() {
var port;
2013-11-12 00:28:37 +08:00
port = new Cylon.Port("192.168.0.1:8080");
2013-10-25 05:25:42 +08:00
it("#port", function() {
return port.port.should.be.equal("8080");
});
it("#isTcp", function() {
return port.isTcp.should.be["true"];
});
it("#isSerial", function() {
return port.isSerial.should.be["false"];
});
it("#isPortless", function() {
return port.isPortless.should.be["false"];
});
return it("#toString", function() {
return port.toString().should.be.equal("192.168.0.1:8080");
});
});
describe("local TCP port", function() {
var port;
2013-11-12 00:28:37 +08:00
port = new Cylon.Port("5678");
2013-10-25 05:25:42 +08:00
it("#port", function() {
return port.port.should.be.equal("5678");
});
it("#isTcp", function() {
return port.isTcp.should.be["true"];
});
it("#isSerial", function() {
return port.isSerial.should.be["false"];
});
it("#isPortless", function() {
return port.isPortless.should.be["false"];
});
return it("#toString", function() {
return port.toString().should.be.equal("localhost:5678");
});
});
describe("serial port", function() {
var port;
2013-11-12 00:28:37 +08:00
port = new Cylon.Port("/dev/tty.usb12345");
2013-10-25 05:25:42 +08:00
it("#port", function() {
return port.port.should.be.equal("/dev/tty.usb12345");
});
it("#isTcp", function() {
return port.isTcp.should.be["false"];
});
it("#isSerial", function() {
return port.isSerial.should.be["true"];
});
it("#isPortless", function() {
return port.isPortless.should.be["false"];
});
return it("#toString", function() {
return port.toString().should.be.equal("/dev/tty.usb12345");
});
});
return describe("portless", function() {
var port;
2013-11-12 00:28:37 +08:00
port = new Cylon.Port;
2013-10-25 05:25:42 +08:00
it("#port", function() {
return assert(port.port === void 0);
});
it("#isTcp", function() {
return port.isTcp.should.be["false"];
});
it("#isSerial", function() {
return port.isSerial.should.be["false"];
});
it("#isPortless", function() {
return port.isPortless.should.be["true"];
});
return it("#toString", function() {
return port.toString().should.be.equal("none");
});
});
});
}).call(this);