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.

19 lines
729 B

  1. const assert = require('assert');
  2. const EventEmitter = require('events');
  3. const IRCServer = require("../src/server.js");
  4. describe("on('connection')", function () {
  5. it("should handle a PING command -> PING irc.example.com", function (done) {
  6. const server = IRCServer.create()
  7. let mockedSock = new EventEmitter()
  8. mockedSock.write = function (data) {
  9. assert.equal(data.toString("ascii"), "PONG irc.example.com\r\n")
  10. done()
  11. }
  12. mockedSock.destroy = function () {
  13. done("Destroyed socket without answering")
  14. }
  15. server.emit("connection", mockedSock)
  16. mockedSock.emit('data', Buffer.from("PING irc.example.com\r\n", "ascii"))
  17. })
  18. })