Browse Source

Add real unit tests for channel

Before we tested channel implicitly by running it through the tests on
the server.js. After some learning today, it's time to add an own set of
unit tests to channel.
test/channel
Sheogorath 6 years ago
parent
commit
e879f3814e
No known key found for this signature in database GPG Key ID: 1F05CC3635CDDFFD
  1. 23
      test/channel.js

23
test/channel.js

@ -0,0 +1,23 @@
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)
})
})
})
Loading…
Cancel
Save