Skip to content

Commit b09456d

Browse files
prashanth-92marcbachmann
authored andcommitted
Keeping Linter happy
1 parent d7997d6 commit b09456d

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

src/handle_request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ function handleRequest(mockAdapter, resolve, reject, config) {
162162
}
163163
}
164164

165-
function getEffectiveDelay(adapter, handler){
165+
function getEffectiveDelay(adapter, handler) {
166166
var delayPerRequest;
167-
if(handler.length === 8){
167+
if (handler.length === 8) {
168168
delayPerRequest = handler[7];
169169
}
170170
return delayPerRequest ? delayPerRequest : adapter.delayResponse;

src/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ VERBS.concat("any").forEach(function (method) {
9797
return _this;
9898
}
9999

100-
function withDelayInMs(delay){
101-
return (code, response, headers) => replyWithDelay(delay, code, response, headers);
100+
function withDelayInMs(delay) {
101+
return function (code, response, headers) {
102+
replyWithDelay(delay, code, response, headers);
103+
};
102104
}
103105

104106
function replyOnce(code, response, headers) {
@@ -119,7 +121,7 @@ VERBS.concat("any").forEach(function (method) {
119121
reply: reply,
120122

121123
replyOnce: replyOnce,
122-
124+
123125
withDelayInMs: withDelayInMs,
124126

125127
passThrough: function passThrough() {

test/basics.spec.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -555,61 +555,61 @@ describe("MockAdapter basics", function () {
555555
expect(message).to.equal("error");
556556
});
557557
});
558-
558+
559559
it("allows delay in millsecond per request", function () {
560560
mock = new MockAdapter(instance);
561-
const start = new Date().getTime();
562-
const firstDelay = 100;
563-
const secondDelay = 500;
564-
const success = 200;
561+
var start = new Date().getTime();
562+
var firstDelay = 100;
563+
var secondDelay = 500;
564+
var success = 200;
565565

566-
const fooOnDelayResponds = mock.onGet("/foo").withDelayInMs(firstDelay);
566+
var fooOnDelayResponds = mock.onGet("/foo").withDelayInMs(firstDelay);
567567
fooOnDelayResponds(success);
568-
const barOnDelayResponds = mock.onGet("/bar").withDelayInMs(secondDelay);
568+
var barOnDelayResponds = mock.onGet("/bar").withDelayInMs(secondDelay);
569569
barOnDelayResponds(success);
570570

571571
return Promise.all([
572572
instance.get("/foo").then(function (response) {
573-
const end = new Date().getTime();
574-
const totalTime = end - start;
575-
573+
var end = new Date().getTime();
574+
var totalTime = end - start;
575+
576576
expect(response.status).to.equal(success);
577577
expect(totalTime).greaterThanOrEqual(firstDelay);
578578
}),
579579
instance.get("/bar").then(function (response) {
580-
const end = new Date().getTime();
581-
const totalTime = end - start;
580+
var end = new Date().getTime();
581+
var totalTime = end - start;
582582

583583
expect(response.status).to.equal(success);
584584
expect(totalTime).greaterThanOrEqual(secondDelay);
585585
})
586586
]);
587587
});
588-
588+
589589
it("overrides global delay if request per delay is provided and respects global delay if otherwise", function () {
590-
const start = new Date().getTime();
591-
const requestDelay = 100;
592-
const globalDelay = 500;
593-
const success = 200;
590+
var start = new Date().getTime();
591+
var requestDelay = 100;
592+
var globalDelay = 500;
593+
var success = 200;
594594
mock = new MockAdapter(instance, { delayResponse: globalDelay });
595-
596-
const fooOnDelayResponds = mock.onGet("/foo").withDelayInMs(requestDelay);
595+
596+
var fooOnDelayResponds = mock.onGet("/foo").withDelayInMs(requestDelay);
597597
fooOnDelayResponds(success);
598598
mock.onGet("/bar").reply(success);
599599

600600
return Promise.all([
601601
instance.get("/foo").then(function (response) {
602-
const end = new Date().getTime();
603-
const totalTime = end - start;
604-
602+
var end = new Date().getTime();
603+
var totalTime = end - start;
604+
605605
expect(response.status).to.equal(success);
606606
expect(totalTime).greaterThanOrEqual(requestDelay);
607607
//Ensure global delay is not applied
608608
expect(totalTime).lessThan(globalDelay);
609609
}),
610610
instance.get("/bar").then(function (response) {
611-
const end = new Date().getTime();
612-
const totalTime = end - start;
611+
var end = new Date().getTime();
612+
var totalTime = end - start;
613613

614614
expect(response.status).to.equal(success);
615615
expect(totalTime).greaterThanOrEqual(globalDelay);

0 commit comments

Comments
 (0)