From 1306db1929db7701bb9d99fab2361568201a434a Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 16 Jul 2019 23:15:33 +0200 Subject: [PATCH] Merge branch 'develop' of https://gogs.informatik.hs-fulda.de/sheogorath/ircd-js into feature/command_quit # Conflicts: # src/server.js # src/user.js # test/command_quit.js --- test/command_privmsg.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/command_privmsg.js diff --git a/test/command_privmsg.js b/test/command_privmsg.js new file mode 100644 index 0000000..9f5466b --- /dev/null +++ b/test/command_privmsg.js @@ -0,0 +1,28 @@ +const assert = require('assert'); +const EventEmitter = require('events'); +const IRCServer = require("../src/server.js"); + +describe("PRIVMSG OK", function () { + it("should handle a PRIVMSG command -> PRIVMSG some_nick :I'm a message", 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) { + let answer = data.toString("ascii") + if (answer.indexOf("PRIVMSG") >= 0) { + assert.equal(answer, ":some_nick PRIVMSG some_nick :I'm a message") + 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")) + mockedSock.emit('data', Buffer.from("PRIVMSG some_nick :I'm a message\r\n", "ascii")) + }) +})