-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: added 3 test cases for 200 result/200 tups delivery
- Loading branch information
Showing
6 changed files
with
93 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('babel/register')({ | ||
optional: ['runtime', 'es7.asyncFunctions'] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
"description": "Slack with Wolfram|Alpha", | ||
"main": "app.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"test": "mocha --require mocha-babel", | ||
"start": "node app.js" | ||
}, | ||
"author": "Jasper Mishra <[email protected]> (https://www.linkedin.com/profile/view?id=168344449)", | ||
|
@@ -20,5 +20,10 @@ | |
"nconf": "^0.7.1", | ||
"request": "^2.58.0", | ||
"xml2js": "^0.4.9" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.2.0", | ||
"mocha": "^2.2.5", | ||
"supertest": "^1.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import mocha from 'mocha'; | ||
import {assert, should, expect} from 'chai'; | ||
import request from 'supertest'; | ||
import apiServer from '../apiServer'; | ||
|
||
describe('Inegration tests', function(){ | ||
let appObj = apiServer.app; | ||
describe('testing posts to wolfram server ', function(){ | ||
this.timeout(0); //disabling timeout coz Wolfram|Alpha takes way too long in comparison to Mocha's optimism | ||
let textObj = {text: "wolfram parabola"}; | ||
it("posts 'wolfram parabola' and gets 200", function(done){ | ||
let textObj = {text: "wolfram parabola"}; | ||
request(appObj) | ||
.post('/wolframBot') | ||
.type('form') | ||
.send(textObj) | ||
.end( (err, res) => { | ||
if(err) return done(err); | ||
expect(res.body.attachments).to.exist; | ||
expect(res.body.attachments).have.length.above(0); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("posts 'wofram What bands have recorded a version of Eleanor Rigby?' and gets 200 with response", function(done){ | ||
let textObj = {text: 'wolfram What bands have recorded a version of Eleanor Rigby?'}; | ||
request(appObj) | ||
.post('/wolframBot') | ||
.type('form') | ||
.send(textObj) | ||
.end(function(err, res){ | ||
if(err) return done(err); | ||
expect(res.body.attachments).to.exist; | ||
expect(res.body.attachments).have.length.above(0); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("post 'wofram wqruohsabfkasbfas and returns res.200 with tips response", function(done){ | ||
let textObj = {text: 'wqruohsabfkasbfas'}; | ||
request(appObj) | ||
.post('/wolframBot') | ||
.type('form') | ||
.send(textObj) | ||
.end(function(err, res){ | ||
if(err) return done(err); | ||
expect(res.body.text).to.equal('Error while processing query'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters