|
|
@ -0,0 +1,24 @@ |
|
|
|
const assert = require('assert'); |
|
|
|
const EventEmitter = require('events'); |
|
|
|
const IRCServer = require("../src/server.js"); |
|
|
|
|
|
|
|
describe("PASS OK", function () { |
|
|
|
it("should handle a PASS command -> PASS some_passwd", function (done) { |
|
|
|
const server = IRCServer.create() |
|
|
|
let mockedSock = new EventEmitter() |
|
|
|
|
|
|
|
|
|
|
|
mockedSock.destroy = function () { |
|
|
|
done("Destroyed socket without answering") |
|
|
|
} |
|
|
|
|
|
|
|
server.emit("connection", mockedSock) |
|
|
|
mockedSock.emit('data', Buffer.from("PASS some_pass\r\n", "ascii")) |
|
|
|
mockedSock.emit('data', Buffer.from("NICK some_nick\r\n", "ascii")) |
|
|
|
|
|
|
|
user = server.getUserlist()["some_nick"] |
|
|
|
assert.equal("some_pass", user["password"]) |
|
|
|
done() |
|
|
|
|
|
|
|
}) |
|
|
|
}) |