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.
24 lines
1.0 KiB
24 lines
1.0 KiB
const assert = require('assert');
|
|
const EventEmitter = require('events');
|
|
const IRCServer = require("../src/server.js");
|
|
|
|
describe("USER OK", function () {
|
|
it("should handle a USER command -> USER guest tolmoon tolsun :Ronnie Reagan", function (done) {
|
|
const server = IRCServer.create()
|
|
let mockedSock = new EventEmitter()
|
|
mockedSock.address = function() {
|
|
return { port: 12346, family: 'IPv4', address: '127.0.0.1' }
|
|
}
|
|
mockedSock.write = function (data) {
|
|
assert.equal(data.toString("ascii"), ":irc.example.com 001 some_nick :Welcome to the example IRC Project some_nick!~guest@127.0.0.1\r\n")
|
|
done()
|
|
}
|
|
mockedSock.destroy = function () {
|
|
done("Destroyed socket without answering")
|
|
}
|
|
|
|
server.emit("connection", mockedSock)
|
|
mockedSock.emit('data', Buffer.from("NICK some_nick\r\n", "ascii"))
|
|
mockedSock.emit('data', Buffer.from("USER guest tolmoon tolsun :Ronnie Reagan\r\n", "ascii"))
|
|
})
|
|
})
|