hapticlink / server /test /socket /routes /test_connection.spec.ts
avallef's picture
Formatted with prettier
d32b1fb
import { expect } from "chai";
import { Context, HapticLinkServer, User } from "../../../src/socket/hapticLinkServer";
import {
TestConnectionHandler,
TestConnectionPayload,
} from "../../../src/socket/routes/test_connection";
import { WebSocketWrapper } from "../hapticLinkServer.spec";
describe("Test Connection", () => {
let server: HapticLinkServer = new HapticLinkServer();
const ws = new WebSocketWrapper();
const user = new User(ws);
user.username = "test";
let ctx: Context<TestConnectionPayload> = {
ws: ws,
user: user,
payload: {
route: "test_connection",
},
server: server,
};
it("should return connection response with user", (done) => {
TestConnectionHandler(ctx);
const res = JSON.parse(ws.sendData as string);
expect(res.message).to.equal("test_connection_response", "didn't return message");
expect(res.username).to.equal("test", "didn't return message");
done();
});
});