Fixed a bug where delay wasn't working in the fluent interface. Bumped v to 1.7.2

This commit is contained in:
Dan Hough
2014-06-20 11:13:21 +01:00
parent 9d3732b6fb
commit 54362db964
3 changed files with 25 additions and 3 deletions

View File

@@ -63,6 +63,7 @@ function FluentInterface(server, o) {
delay: function(delay) {
debug('Replacing delay for', originalPath, JSON.stringify(route.request.query), 'with', delay);
route.response.delay = delay;
return this;
},
responseHeaders: function (headers) {
debug('Replacing response headers for', originalPath, JSON.stringify(route.request.query), 'with', headers);

View File

@@ -1,7 +1,7 @@
{
"name": "interfake",
"preferGlobal": true,
"version": "1.7.1",
"version": "1.7.2",
"author": "Daniel Hough <daniel.hough@gmail.com>",
"description": "A simple way to create dummy APIs",
"contributors": [

View File

@@ -738,7 +738,6 @@ describe('Interfake JavaScript API', function () {
describe('#delay()', function() {
it('should create one GET endpoint with a particular delay', function (done) {
var enoughTimeHasPassed = false;
var _this = this;
this.slow(500);
interfake.get('/fluent').delay(50);
interfake.listen(3000);
@@ -746,13 +745,35 @@ describe('Interfake JavaScript API', function () {
enoughTimeHasPassed = true;
}, 50);
request({ url : 'http://localhost:3000/fluent', json : true }, function (error, response, body) {
request({ url : 'http://localhost:3000/fluent', json : true }, function () {
if(!enoughTimeHasPassed) {
throw new Error('Response wasn\'t delay for long enough');
}
done();
});
});
describe('#body()', function() {
it('should create one GET endpoint with a particular delay and body', function (done) {
var enoughTimeHasPassed = false;
this.slow(500);
interfake.get('/fluent').delay(50).body({
ok: 'yeah'
});
interfake.listen(3000);
setTimeout(function() {
enoughTimeHasPassed = true;
}, 50);
request({ url : 'http://localhost:3000/fluent', json : true }, function (error, response, body) {
if(!enoughTimeHasPassed) {
throw new Error('Response wasn\'t delay for long enough');
}
assert.equal(body.ok, 'yeah');
done();
});
});
});
});
});