You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
1.0 KiB

  1. const assert = require('assert');
  2. const EventEmitter = require('events');
  3. const IRCServer = require("../src/server.js");
  4. describe("USER OK", function () {
  5. it("should handle a USER command -> USER guest tolmoon tolsun :Ronnie Reagan", function (done) {
  6. const server = IRCServer.create()
  7. let mockedSock = new EventEmitter()
  8. mockedSock.address = function() {
  9. return { port: 12346, family: 'IPv4', address: '127.0.0.1' }
  10. }
  11. mockedSock.write = function (data) {
  12. assert.equal(data.toString("ascii"), ":irc.example.com 001 some_nick :Welcome to the example IRC Project some_nick!~guest@127.0.0.1\r\n")
  13. done()
  14. }
  15. mockedSock.destroy = function () {
  16. done("Destroyed socket without answering")
  17. }
  18. server.emit("connection", mockedSock)
  19. mockedSock.emit('data', Buffer.from("NICK some_nick\r\n", "ascii"))
  20. mockedSock.emit('data', Buffer.from("USER guest tolmoon tolsun :Ronnie Reagan\r\n", "ascii"))
  21. })
  22. })