discord-irc/test/channel-mapping.test.js
Edward Jones c0d443d9c5 Move from irc 0.5.2 to irc-upd 0.6.1
The irc module does not appear to be very actively maintained, and has
quite a few issues causing issues in this project itself.

This fork, maintained by me, has a few fixes to some major issues
already.

Changelogs:

- v0.6.0 - https://github.com/Throne3d/node-irc/releases/tag/v0.6.0
- v0.6.1 - https://github.com/Throne3d/node-irc/releases/tag/v0.6.1

Should fix #199, #200, as well as some issues not previously noted
(crash if unbanning a user who is not banned, crash in circumstances
with a poor internet connection).

It may also allow us to remove our workaround for the quit and nick
events having all channels in the associated array.
2017-07-01 17:29:33 +01:00

56 lines
1.7 KiB
JavaScript

import chai from 'chai';
import irc from 'irc-upd';
import discord from 'discord.js';
import Bot from '../lib/bot';
import config from './fixtures/single-test-config.json';
import caseConfig from './fixtures/case-sensitivity-config.json';
import DiscordStub from './stubs/discord-stub';
import ClientStub from './stubs/irc-client-stub';
import { validateChannelMapping } from '../lib/validators';
chai.should();
describe('Channel Mapping', () => {
before(() => {
irc.Client = ClientStub;
discord.Client = DiscordStub;
});
it('should fail when not given proper JSON', () => {
const wrongMapping = 'not json';
function wrap() {
validateChannelMapping(wrongMapping);
}
(wrap).should.throw('Invalid channel mapping given');
});
it('should not fail if given a proper channel list as JSON', () => {
const correctMapping = { '#channel': '#otherchannel' };
function wrap() {
validateChannelMapping(correctMapping);
}
(wrap).should.not.throw();
});
it('should clear channel keys from the mapping', () => {
const bot = new Bot(config);
bot.channelMapping['#discord'].should.equal('#irc');
bot.invertedMapping['#irc'].should.equal('#discord');
bot.channels.should.contain('#irc channelKey');
});
it('should lowercase IRC channel names', () => {
const bot = new Bot(caseConfig);
bot.channelMapping['#discord'].should.equal('#irc');
bot.channelMapping['#otherDiscord'].should.equal('#otherirc');
});
it('should work with ID maps', () => {
const bot = new Bot(config);
bot.channelMapping['1234'].should.equal('#channelforid');
bot.invertedMapping['#channelforid'].should.equal('1234');
});
});