riot-translatebot

A simple riot bot which provides Status about Weblate
git clone git://archive.git.mtrnord.blog/Nordgedanken/riot-translatebot.git
Log | Files | Refs | README | LICENSE

commit 416c9c437bdfcc01beb5c497353226c2c66b4834
parent fb0597606b8bc85f759675597f0827ce8fbe6547
Author: Marcel <mtrnord1@gmail.com>
Date:   Tue, 20 Jun 2017 12:56:52 +0200

Add Basic test for languages. And use else if

Signed-off-by: Marcel <mtrnord1@gmail.com>

Diffstat:
Msrc/commands.js | 4++--
Msrc/index.js | 3+--
Mtest/commands_test.js | 6++++++
3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/commands.js b/src/commands.js @@ -6,11 +6,11 @@ export default class Commands { } help = room => { - return this.client.sendHtmlNotice(room.roomId, `Help for you!\n Commands:\n * !language`, `Help for you!<br> Commands:<br> <ul><li>None</li></ul>`).catch(error => console.log(error)); + return this.client.sendHtmlNotice(room.roomId, `Help for you!\n Commands:\n * !languages`, `Help for you!<br> Commands:<br> <ul><li>languages</li></ul>`).catch(error => console.log(error)); }; languages = room => { - this.weblate.getLangs().then(body => { + return this.weblate.getLangs().then(body => { let message = 'Currently known languages:\n'; for (let key in body['results']) { message += body['results'][key]['code'] + '\n' diff --git a/src/index.js b/src/index.js @@ -23,8 +23,7 @@ mx.getClient().then(client => { "(%s) %s :: %s", room.name, event.getSender(), message ); commands.help(room); - } - if (message.startsWith("!languages")){ + } else if (message.startsWith("!languages")){ console.log( "(%s) %s :: %s", room.name, event.getSender(), message ); diff --git a/test/commands_test.js b/test/commands_test.js @@ -16,5 +16,11 @@ describe('Commands', () => { const help = CommandHandler.help(room); help.should.be.fulfilled.and.notify(done); }); + it('should send languages', done => { + const CommandHandler = new Commands(client); + const room = {roomId: '!EDuQpgunAOTYiUKIcU:matrix.org'}; + const languages = CommandHandler.languages(room); + languages.should.be.fulfilled.and.notify(done); + }); }); }); \ No newline at end of file