Browse Source

added NICK no NICK given test + implementation with new errorcode

feature/extend_user
Wayne 6 years ago
parent
commit
9937934443
  1. 3
      src/server.js
  2. 18
      test/server.js

3
src/server.js

@ -7,6 +7,7 @@ const ERR_NOSUCHCHANNEL = '403'
const ERR_CANNOTSENDTOCHAN = '404'
const ERR_UNKNOWNCOMMAND = '421'
const ERR_ERRONEUSNICKNAME = '432'
const ERR_NONICKNAMEGIVEN = '431'
const ERR_NICKNAMEINUSE = '433'
const ERR_NEEDMOREPARAMS = '461'
@ -39,7 +40,7 @@ server.create = function create() {
} else {
socket.write("ERROR: NO NICKNAME PROVIDED")
socket.write(ERR_NONICKNAMEGIVEN, "ERROR: NO NICKNAME PROVIDED")
}
break;

18
test/server.js

@ -40,7 +40,7 @@ describe('IRC server', function () {
server.emit("connection", mockedSock)
mockedSock.emit('data', Buffer.from("NICK some_nick\r\n", "ascii"))
})
}),
})
describe("NICK already registered", function () {
it("should handle a NICK command -> NICK some_nickname", function (done) {
const server = IRCServer.create()
@ -57,4 +57,20 @@ describe('IRC server', function () {
mockedSock.emit('data', Buffer.from("NICK some_nick\r\n", "ascii"))
})
})
describe("NICK no NICK given", function () {
it("should handle a NICK command -> NICK ", function (done) {
const server = IRCServer.create()
let mockedSock = new EventEmitter()
mockedSock.write = function (data) {
assert.equal(data.toString("ascii"), "431")
done()
}
mockedSock.destroy = function () {
done("Destroyed socket without answering")
}
server.emit("connection", mockedSock)
mockedSock.emit('data', Buffer.from("NICK \r\n", "ascii"))
})
})
})
Loading…
Cancel
Save