mirror of
https://github.com/status-im/autobounty.git
synced 2025-02-09 04:03:51 +00:00
Mocha testing pipeline and first test
This commit is contained in:
parent
aa98585bae
commit
e028a2e8d8
@ -16,11 +16,11 @@ const logger = winston.createLogger({
|
||||
|
||||
|
||||
const needsFunding = function(req) {
|
||||
if (req.body.action !== 'created' || !req.body.hasOwnProperty('comment'))
|
||||
if (req.body.action !== 'created' || !req.body.hasOwnProperty('comment')) {
|
||||
return false
|
||||
//else if (req.comment.user.login !== 'status-open-bounty')
|
||||
// return false
|
||||
|
||||
} else if (req.body.comment.user.login !== 'status-open-bounty') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,13 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "./node_modules/mocha/bin/mocha"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"body-parser": "^1.17.2",
|
||||
"chai": "^4.1.2",
|
||||
"cors": "^2.8.1",
|
||||
"eslint": "^4.15.0",
|
||||
"ethjs-provider-signer": "^0.1.4",
|
||||
@ -19,6 +20,7 @@
|
||||
"express": "^4.15.2",
|
||||
"helmet": "^3.9.0",
|
||||
"lodash": "^4.17.4",
|
||||
"mocha": "^5.0.0",
|
||||
"web3": "^0.18.2",
|
||||
"winston": "^3.0.0-rc1"
|
||||
}
|
||||
|
33
test/test_bot.js
Normal file
33
test/test_bot.js
Normal file
@ -0,0 +1,33 @@
|
||||
const chai = require('chai');
|
||||
const expect = require('chai').expect;
|
||||
const assert = require('chai').assert;
|
||||
const should = require('chai').should;
|
||||
const bot = require('../bot')
|
||||
|
||||
// status-open-bounty comment from https://github.com/status-im/autobounty/issues/1
|
||||
let sob_comment = 'Current balance: 0.000000 ETH\nTokens: SNT: 2500.00 ANT: 25.00\nContract address: 0x3645fe42b1a744ad98cc032c22472388806f86f9\nNetwork: Mainnet\n To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.\nTo fund it, send ETH or ERC20/ERC223 tokens to the contract address.'
|
||||
|
||||
// Fake requests
|
||||
let requests = [
|
||||
{body: {action: 'created', comment: {body: 'Creating my first comment', user: {login: 'jomsdev'}}}},
|
||||
{body: {action: 'edited', comment: {body: 'Editing my comment', user: {login: 'jomsdev'}}}},
|
||||
{body: {action: 'edited', comment: {body: sob_comment, user: {login: 'status-open-bounty'}}}},
|
||||
{body: {action: 'created', comment: {body: sob_comment, user: {login: 'status-open-bounty'}}}}
|
||||
];
|
||||
|
||||
describe('Bot behavior', function() {
|
||||
describe('#needsFunding()', function() {
|
||||
it('should return false because the comment is not from status-open-bounty', function() {
|
||||
assert.isFalse(bot.needsFunding(requests[0]));
|
||||
});
|
||||
it('should return false because a user is editing a comment', function() {
|
||||
assert.isFalse(bot.needsFunding(requests[1]));
|
||||
});
|
||||
it('should return false because status-open-bounty edited a comment', function() {
|
||||
assert.isFalse(bot.needsFunding(requests[2]));
|
||||
});
|
||||
it('should return true, it is all right and we should fund', function() {
|
||||
assert.isTrue(bot.needsFunding(requests[3]));
|
||||
});
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user