smartsocket/test/test.js

37 lines
2.9 KiB
JavaScript
Raw Normal View History

2016-08-07 12:58:20 +00:00
"use strict";
require("typings-test");
require("should");
const socketIoClient = require("socket.io-client");
const smartsocket = require("../dist/index");
let testSmartsocket;
describe("smartsocket", function () {
it("should create a new smartsocket", function () {
testSmartsocket = new smartsocket.Smartsocket({ port: 3000 });
testSmartsocket.should.be.instanceOf(smartsocket.Smartsocket);
});
2016-08-07 16:59:39 +00:00
it("should register a new Function", function () {
});
it("should start listening when .started is called", function () {
testSmartsocket.startServer();
});
2016-08-07 12:58:20 +00:00
it("should react to a new websocket connection", function (done) {
this.timeout(10000);
let socket = socketIoClient("http://localhost:3000", {});
socket.on("requestAuth", function () {
console.log("server requested authentication");
socket.emit("dataAuth", {
2016-08-07 16:59:39 +00:00
role: "coreflowContainer",
password: "somePassword",
alias: "coreflow1"
});
socket.on("authenticated", () => {
console.log("client is authenticated");
done();
2016-08-07 12:58:20 +00:00
});
});
});
2016-08-07 16:59:39 +00:00
it("should close the server", function () {
testSmartsocket.closeServer();
});
2016-08-07 12:58:20 +00:00
});
2016-08-07 16:59:39 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUNoQixNQUFPLGNBQWMsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBQ3BELE1BQU8sV0FBVyxXQUFXLGVBQWUsQ0FBQyxDQUFDO0FBRTlDLElBQUksZUFBd0MsQ0FBQztBQUU3QyxRQUFRLENBQUMsYUFBYSxFQUFFO0lBQ3BCLEVBQUUsQ0FBQyxpQ0FBaUMsRUFBRTtRQUNsQyxlQUFlLEdBQUcsSUFBSSxXQUFXLENBQUMs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