Fix API not returning anything if bad URL

This commit is contained in:
Gaël Métais
2015-01-06 16:41:17 +01:00
parent aee0905ea5
commit 079ec94197
2 changed files with 49 additions and 1 deletions
+44
View File
@@ -41,6 +41,50 @@ describe('api', function() {
});
});
it('should fail without an URL when asynchronous', function(done) {
this.timeout(15000);
request({
method: 'POST',
url: serverUrl + '/api/runs',
body: {
url: ''
},
json: true,
headers: {
'X-Api-Key': Object.keys(config.authorizedKeys)[0]
}
}, function(error, response, body) {
if (!error && response.statusCode === 400) {
done();
} else {
done(error || response.statusCode);
}
});
});
it('should fail without an URL when synchronous', function(done) {
this.timeout(15000);
request({
method: 'POST',
url: serverUrl + '/api/runs',
body: {
url: '',
waitForResponse: true
},
json: true,
headers: {
'X-Api-Key': Object.keys(config.authorizedKeys)[0]
}
}, function(error, response, body) {
if (!error && response.statusCode === 400) {
done();
} else {
done(error || response.statusCode);
}
});
});
it('should launch a synchronous run', function(done) {
this.timeout(15000);