Browse Source
Fix: Real world messages
Fix: Real world messages
IRC is specified to have `\r\n` at the end of each command. If not messages are not considered complete. This patch fixes our implementation to answer with real command aka. things that end with `\r\n`.feature/index.js
Sheogorath
5 years ago
No known key found for this signature in database
GPG Key ID: 1F05CC3635CDDFFD
5 changed files with 83 additions and 55 deletions
@ -0,0 +1,23 @@ |
|||
const assert = require('assert'); |
|||
const EventEmitter = require('events'); |
|||
const IRCServer = require("../src/server.js"); |
|||
|
|||
describe("hexchat", function () { |
|||
it("should handle hexchat inital command list", 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"), "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("CAP LS 302\r\nNICK some_nick\r\nUSER guest tolmoon tolsun :Ronnie Reagan\r\n", "ascii")) |
|||
}) |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue