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 478d73696fbce19246c224c167e9e3c3ebcc77cc
parent bd3e64aa30da41a5d11ca0ff7dffefe1ed100b24
Author: Marcel <mtrnord1@gmail.com>
Date:   Tue, 20 Jun 2017 09:48:03 +0200

Add command Tests

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

Diffstat:
MREADME.md | 10++++++++++
Msrc/commands.js | 4++--
Msrc/login.js | 2+-
Mtest/commands_test.js | 16++++++++++------
Mtest/login_test.js | 4++--
5 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md @@ -2,3 +2,12 @@ # Riot-TranslateBot A simple riot bot which provides Status about Weblate + +# Tests +``` +1. npm install +2. npm run start "USERNAME" "PASSWORD" +3. kill npm run start after it got the poll rules +4. npm test +``` +``npm run start`` is required as it generates the needed token file. Using "USERNAME" and "PASSWORD" on npm test will propably work too. +\ No newline at end of file diff --git a/src/commands.js b/src/commands.js @@ -1,9 +1,9 @@ -export default class commands { +export default class Commands { constructor(client){ this.client = client; } help = room => { - this.client.sendHtmlNotice(room.roomId, `Help for you!\r\n Commands:\r\n - None`, `Help for you!<br> Commands:<br> - None`).catch(error => console.log(error)); + return this.client.sendHtmlNotice(room.roomId, `Help for you!\r\n Commands:\r\n - None`, `Help for you!<br> Commands:<br> - None`).catch(error => console.log(error)); } } diff --git a/src/login.js b/src/login.js @@ -4,7 +4,7 @@ import node_fs from 'fs'; const env_args = process.argv.splice(process.execArgv.length + 2); -export default class Client { +export default class Login { constructor() {}; getClient = () => { return this.login(); diff --git a/test/commands_test.js b/test/commands_test.js @@ -1,16 +1,20 @@ import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import login from '../lib/login'; -import commands from '../lib/commands'; +import Login from '../lib/login'; +import Commands from '../lib/commands'; chai.use(chaiAsPromised); chai.should(); describe('Commands', () => { - const mx = new login; - mx.getClient().then(() => { - //TODO add test - it('should answer with help'); + const mx = new Login; + mx.getClient().then(client => { + it('should send help', done => { + const CommandHandler = new Commands(client); + const room = {roomId: '!EDuQpgunAOTYiUKIcU:matrix.org'}; + const help = CommandHandler.help(room); + help.should.be.fulfilled.and.notify(done); + }); }); }); \ No newline at end of file diff --git a/test/login_test.js b/test/login_test.js @@ -1,6 +1,6 @@ import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import login from '../lib/login'; +import Login from '../lib/login'; import chai_fs from 'chai-fs'; chai.use(chai_fs); @@ -11,7 +11,7 @@ const expect = chai.expect; chai.should(); describe('Login', () => { - const mx = new login; + const mx = new Login; it('should eventually login', done => { const client = mx.getClient(); client.should.be.fulfilled.and.notify(done);