Add integration tests
This commit is contained in:
parent
b25909a14b
commit
1b926b75c7
4 changed files with 142 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
|||
node_modules/
|
||||
t.js
|
||||
test/secrets.js
|
||||
|
|
137
test/integration.js
Normal file
137
test/integration.js
Normal file
|
@ -0,0 +1,137 @@
|
|||
|
||||
// Try to get an access key to run all this test.
|
||||
// If the file doesn't exist or it doesn't contain an access key, it
|
||||
// should still run the basic tests; thus throwing an exception must
|
||||
// be avoided.
|
||||
try{
|
||||
var accKey = require('./secrets').accKey;
|
||||
}
|
||||
catch(e){ console.log(e) }
|
||||
|
||||
if(!accKey){
|
||||
return console.error("Need to include an access key in your secrets.js");
|
||||
}
|
||||
|
||||
|
||||
var Bing = require('../')({ accKey: accKey})
|
||||
, should = require('should')
|
||||
|
||||
|
||||
describe("Bing Search", function(){
|
||||
|
||||
this.timeout(1000 * 10);
|
||||
|
||||
it('works without options', function(done){
|
||||
|
||||
Bing.search('nigger vs chink', function(err, res, body){
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(res);
|
||||
should.exist(body);
|
||||
|
||||
body.d.results.should.have.length(50);
|
||||
|
||||
//TODO check it contains the right fields
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('finds only 5 results', function(done){
|
||||
Bing.search('nigger vs chink', function(err, res, body){
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(res);
|
||||
should.exist(body);
|
||||
|
||||
body.d.results.should.have.length(5);
|
||||
|
||||
done();
|
||||
},
|
||||
{
|
||||
top: 5,
|
||||
market: 'en-US',
|
||||
adult: 'Strict'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe("Bing Images", function(){
|
||||
|
||||
this.timeout(1000 * 10);
|
||||
|
||||
it('finds images with specific options', function(done){
|
||||
Bing.images('pizza',
|
||||
function(err, res, body){
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(res);
|
||||
should.exist(body);
|
||||
|
||||
body.d.results.should.have.length(3);
|
||||
|
||||
done();
|
||||
},
|
||||
{
|
||||
top: 3,
|
||||
adult: 'Off',
|
||||
imagefilters: { size: 'small', color: 'monochrome' }
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe("Bing News", function(){
|
||||
|
||||
this.timeout(1000 * 10);
|
||||
|
||||
it('finds news with specific options', function(done){
|
||||
|
||||
Bing.news('ps4', function(err, res, body){
|
||||
//TODO try unaccepted options like imagefilters
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(res);
|
||||
should.exist(body);
|
||||
|
||||
body.d.results.should.have.length(10);
|
||||
|
||||
done();
|
||||
},
|
||||
{
|
||||
top: 10,
|
||||
skip: 1,
|
||||
newsortby: 'Date'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
describe("Bing Video", function(){
|
||||
|
||||
this.timeout(1000 * 10);
|
||||
|
||||
it('finds videos with specific options', function(done){
|
||||
|
||||
Bing.video('monkey vs frog', function(err, res, body){
|
||||
|
||||
should.not.exist(err);
|
||||
should.exist(res);
|
||||
should.exist(body);
|
||||
|
||||
body.d.results.should.have.length(10);
|
||||
|
||||
//TODO try here unaccepted options like imagefilters
|
||||
|
||||
done();
|
||||
},
|
||||
{
|
||||
top: 10
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
4
test/secrets.js.example
Normal file
4
test/secrets.js.example
Normal file
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
accKey: ''
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue