Skip to content

Commit 16b7522

Browse files
authored
tests: reenable some tests (#503)
They were giving compiler errors in CI, but now they work (maybe because of the upgrade to Node in [1]?). [1] 439d043 Fixes #494
1 parent 1f0109b commit 16b7522

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

Diff for: tests/bot_test.js

+29-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require('dotenv').config();
2-
// const path = require('path');
3-
// const fs = require('fs');
2+
const path = require('path');
3+
const fs = require('fs');
44
const TelegramServer = require('telegram-test-api');
55
const sinon = require('sinon');
66
const { expect } = require('chai');
@@ -9,7 +9,7 @@ const { User, Order } = require('../models');
99
const ordersActions = require('../bot/ordersActions');
1010
const testUser = require('./user');
1111
const testOrder = require('./order');
12-
// const { getCurrenciesWithPrice } = require('../util');
12+
const { getCurrenciesWithPrice } = require('../util');
1313
const { connect: mongoConnect } = require('../db_connect');
1414

1515
mongoConnect();
@@ -114,33 +114,32 @@ describe('Telegram bot test', () => {
114114
const command = client.makeCommand('/listcurrencies');
115115
const res = await client.sendCommand(command);
116116
expect(res.ok).to.be.equal(true);
117-
// const updates = await client.getUpdates();
118-
// userStub.restore();
119-
// expect(updates.ok).to.be.equal(true);
120-
// expect(
121-
// (updates.result[0].message.text.match(/\n/g) || []).length - 1
122-
// ).to.be.equal(getCurrenciesWithPrice().length);
117+
const updates = await client.getUpdates();
118+
userStub.restore();
119+
expect(updates.ok).to.be.equal(true);
120+
expect(
121+
(updates.result[0].message.text.match(/\n/g) || []).length - 1
122+
).to.be.equal(getCurrenciesWithPrice().length);
123123
});
124124

125-
// it('should return flags of langs supported', async () => {
126-
// const client = server.getClient(token, { timeout: 5000 });
127-
// const userStub = sinon.stub(User, 'findOne');
128-
// userStub.returns(testUser);
129-
// const command = client.makeCommand('/setlang');
130-
// const res = await client.sendCommand(command);
131-
// console.log(res);
132-
// expect(res.ok).to.be.equal(true);
133-
// const updates = await client.getUpdates();
134-
// userStub.restore();
135-
// expect(updates.ok).to.be.equal(true);
136-
// let flags = 0;
137-
// updates.result[0].message.reply_markup.inline_keyboard.forEach(flag => {
138-
// flags += flag.length;
139-
// });
140-
// let langs = 0;
141-
// fs.readdirSync(path.join(__dirname, '../locales')).forEach(file => {
142-
// langs++;
143-
// });
144-
// expect(flags).to.be.equal(langs);
145-
// });
125+
it('should return flags of langs supported', async () => {
126+
const client = server.getClient(token, { timeout: 5000 });
127+
const userStub = sinon.stub(User, 'findOne');
128+
userStub.returns(testUser);
129+
const command = client.makeCommand('/setlang');
130+
const res = await client.sendCommand(command);
131+
expect(res.ok).to.be.equal(true);
132+
const updates = await client.getUpdates();
133+
userStub.restore();
134+
expect(updates.ok).to.be.equal(true);
135+
let flags = 0;
136+
updates.result[0].message.reply_markup.inline_keyboard.forEach(flag => {
137+
flags += flag.length;
138+
});
139+
let langs = 0;
140+
fs.readdirSync(path.join(__dirname, '../locales')).forEach(file => {
141+
langs++;
142+
});
143+
expect(flags).to.be.equal(langs);
144+
});
146145
});

0 commit comments

Comments
 (0)