Skip to content

Commit ba505ed

Browse files
committed
Add unit tests for IRC-style initial mentions (#470)
1 parent d7d3bd6 commit ba505ed

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

test/bot.test.js

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ describe('Bot', function () {
432432
this.bot.parseText(message).should.equal(':in_love:');
433433
});
434434

435-
it('should convert user mentions from IRC', function () {
435+
it('should convert user at-mentions from IRC', function () {
436436
const testUser = this.addUser({ username: 'testuser', id: '123' });
437437

438438
const username = 'ircuser';
@@ -443,7 +443,40 @@ describe('Bot', function () {
443443
this.sendStub.should.have.been.calledWith(expected);
444444
});
445445

446-
it('should not convert user mentions from IRC if such user does not exist', function () {
446+
it('should convert user colon-initial mentions from IRC', function () {
447+
const testUser = this.addUser({ username: 'testuser', id: '123' });
448+
449+
const username = 'ircuser';
450+
const text = 'testuser: hello!';
451+
const expected = `**<${username}>** <@${testUser.id}> hello!`;
452+
453+
this.bot.sendToDiscord(username, '#irc', text);
454+
this.sendStub.should.have.been.calledWith(expected);
455+
});
456+
457+
it('should convert user comma-initial mentions from IRC', function () {
458+
const testUser = this.addUser({ username: 'testuser', id: '123' });
459+
460+
const username = 'ircuser';
461+
const text = 'testuser, hello!';
462+
const expected = `**<${username}>** <@${testUser.id}> hello!`;
463+
464+
this.bot.sendToDiscord(username, '#irc', text);
465+
this.sendStub.should.have.been.calledWith(expected);
466+
});
467+
468+
it('should not convert user initial mentions from IRC mid-message', function () {
469+
this.addUser({ username: 'testuser', id: '123' });
470+
471+
const username = 'ircuser';
472+
const text = 'Hi there testuser, how goes?';
473+
const expected = `**<${username}>** Hi there testuser, how goes?`;
474+
475+
this.bot.sendToDiscord(username, '#irc', text);
476+
this.sendStub.should.have.been.calledWith(expected);
477+
});
478+
479+
it('should not convert user at-mentions from IRC if such user does not exist', function () {
447480
const username = 'ircuser';
448481
const text = 'See you there @5pm';
449482
const expected = `**<${username}>** See you there @5pm`;
@@ -452,6 +485,15 @@ describe('Bot', function () {
452485
this.sendStub.should.have.been.calledWith(expected);
453486
});
454487

488+
it('should not convert user initial mentions from IRC if such user does not exist', function () {
489+
const username = 'ircuser';
490+
const text = 'Agreed, see you then.';
491+
const expected = `**<${username}>** Agreed, see you then.`;
492+
493+
this.bot.sendToDiscord(username, '#irc', text);
494+
this.sendStub.should.have.been.calledWith(expected);
495+
});
496+
455497
it('should convert multiple user mentions from IRC', function () {
456498
const testUser = this.addUser({ username: 'testuser', id: '123' });
457499
const anotherUser = this.addUser({ username: 'anotheruser', id: '124' });

0 commit comments

Comments
 (0)