Browse Source
Merge commit '7d02c4d4a56eead8a2b6cc028c3311280b534ae2' into HEAD
feature/command_quit
Merge commit '7d02c4d4a56eead8a2b6cc028c3311280b534ae2' into HEAD
feature/command_quit
Jenkins
5 years ago
5 changed files with 85 additions and 28 deletions
@ -1,18 +1,26 @@ |
|||
const userlist = require("../src/userlist.js") |
|||
|
|||
function User(socket) { |
|||
|
|||
this.registered = false |
|||
this.nickname = "" |
|||
this.user = "" |
|||
this.realname = "" |
|||
|
|||
this.connection = socket |
|||
this.realname = "" |
|||
this.username = "" |
|||
|
|||
this.setNickname = function(nickname) { |
|||
this.nickname = nickname |
|||
} |
|||
this.setRealName = function (realname) { |
|||
|
|||
this.getNickname = function(nickname) { |
|||
return this.nickname |
|||
} |
|||
|
|||
this.register = function(username, realname) { |
|||
this.username = username |
|||
this.realname = realname |
|||
this.registered = true |
|||
} |
|||
|
|||
this.getAddress = function() { |
|||
return this.connection.address().address |
|||
} |
|||
} |
|||
|
|||
|
@ -1,3 +0,0 @@ |
|||
let userlist = {} |
|||
|
|||
module.exports = userlist |
@ -0,0 +1,24 @@ |
|||
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"), "001 some_nick :Welcome to the example IRC Project some_nick!~guest@127.0.0.1") |
|||
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")) |
|||
}) |
|||
}) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue