|
|
@ -0,0 +1,41 @@ |
|
|
|
const assert = require('assert'); |
|
|
|
const Channel = require("../src/channel.js"); |
|
|
|
|
|
|
|
describe('Channel', function () { |
|
|
|
describe('#contructor()', function () { |
|
|
|
it("should create a channel", function () { |
|
|
|
const channel = new Channel("#testchan") |
|
|
|
assert.equal(typeof channel, 'object') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
describe('#join(user)', function () { |
|
|
|
it("should add the user to a channel and send a JOIN command to the user", function (done) { |
|
|
|
const channel = new Channel("#testchan") |
|
|
|
let mockedUser = {nickname: "some_nick"} |
|
|
|
mockedUser.sendRaw = function(data) { |
|
|
|
assert.equal(data, ":some_nick JOIN #testchan") |
|
|
|
done() |
|
|
|
} |
|
|
|
channel.join(mockedUser) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
describe('#part(user)', function () { |
|
|
|
it("should remove a user from a channel and send a PART command to the user", function (done) { |
|
|
|
const channel = new Channel("#testchan") |
|
|
|
let mockedUser = {nickname: "some_nick"} |
|
|
|
mockedUser.sendRaw = function(data) { |
|
|
|
// we expect a PART message from our user to the channel (including us)
|
|
|
|
if (data.indexOf("PART") >= 0) { |
|
|
|
assert.equal(data, ":some_nick PART #testchan") |
|
|
|
done() |
|
|
|
} |
|
|
|
} |
|
|
|
// we can't part a channel without joining it first
|
|
|
|
channel.join(mockedUser) |
|
|
|
|
|
|
|
channel.part(mockedUser) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |