You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
729 B

const assert = require('assert');
const EventEmitter = require('events');
const IRCServer = require("../src/server.js");
describe("on('connection')", function () {
it("should handle a PING command -> PING irc.example.com", function (done) {
const server = IRCServer.create()
let mockedSock = new EventEmitter()
mockedSock.write = function (data) {
assert.equal(data.toString("ascii"), "PONG irc.example.com\r\n")
done()
}
mockedSock.destroy = function () {
done("Destroyed socket without answering")
}
server.emit("connection", mockedSock)
mockedSock.emit('data', Buffer.from("PING irc.example.com\r\n", "ascii"))
})
})