Skip to content

Commit baa2d21

Browse files
committed
Rename waitFor() to delay()
Flipflopping a bit on this, but I think delay is clearer in practice.
1 parent 9c7ef36 commit baa2d21

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/rules/requests/request-rule-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class RequestRuleBuilder extends BaseRuleBuilder {
9393
/**
9494
* Add a delay (in milliseconds) before the next step in the rule
9595
*/
96-
waitFor(ms: number): this {
96+
delay(ms: number): this {
9797
this.steps.push(new DelayStep(ms));
9898
return this;
9999
}

src/rules/websockets/websocket-rule-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class WebSocketRuleBuilder extends BaseRuleBuilder {
5555
/**
5656
* Add a delay (in milliseconds) before the next step in the rule
5757
*/
58-
waitFor(ms: number): this {
58+
delay(ms: number): this {
5959
this.steps.push(new DelayStep(ms));
6060
return this;
6161
}

test/integration/handlers/delay.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("Delay steps", function () {
1515
afterEach(() => server.stop());
1616

1717
it("should do nothing if delaying for 0ms", async () => {
18-
await server.forGet('/mocked-endpoint').waitFor(0).thenReply(200);
18+
await server.forGet('/mocked-endpoint').delay(0).thenReply(200);
1919

2020
const startTime = Date.now();
2121
let result = await fetch(server.urlFor('/mocked-endpoint')).catch(e => e);
@@ -24,7 +24,7 @@ describe("Delay steps", function () {
2424
});
2525

2626
it("should delay if set to a non-zero value", async () => {
27-
await server.forGet('/mocked-endpoint').waitFor(100).thenReply(200);
27+
await server.forGet('/mocked-endpoint').delay(100).thenReply(200);
2828

2929
const startTime = Date.now();
3030
let result = await fetch(server.urlFor('/mocked-endpoint')).catch(e => e);
@@ -34,7 +34,7 @@ describe("Delay steps", function () {
3434

3535
nodeOnly(() => {
3636
it("should also delay websocket responses", async () => {
37-
await server.forAnyWebSocket().waitFor(100).thenRejectConnection(401);
37+
await server.forAnyWebSocket().delay(100).thenRejectConnection(401);
3838

3939
const startTime = Date.now();
4040
const ws = new WebSocket(`ws://localhost:${server.port}`);

0 commit comments

Comments
 (0)