mirror of
https://github.com/zhigang1992/interfake.git
synced 2026-01-12 17:23:07 +08:00
Fixed a bug where delay wasn't working in the fluent interface. Bumped v to 1.7.2
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user