Archived
1
0

Add createServer (#18)

This commit is contained in:
Kyle Carberry
2019-01-23 18:00:38 -06:00
parent ec909bdd0c
commit 6c178d615d
11 changed files with 1671 additions and 50 deletions

View File

@ -198,4 +198,39 @@ describe("createConnection", () => {
});
});
});
});
describe("createServer", () => {
const client = createClient();
const tmpPath = path.join(os.tmpdir(), Math.random().toString());
it("should connect to server", (done) => {
const s = client.createServer(() => {
s.close();
});
s.on("close", () => {
done();
});
s.listen(tmpPath);
});
it("should connect to server and get socket connection", (done) => {
const s = client.createServer();
s.listen(tmpPath, () => {
net.createConnection(tmpPath, () => {
checks++;
s.close();
});
});
let checks = 0;
s.on("connection", (con) => {
expect(checks).toEqual(1);
con.end();
checks++;
});
s.on("close", () => {
expect(checks).toEqual(2);
done();
});
});
});