Skip to content

Commit 89e4e4b

Browse files
committed
docs(responseutils): Added test, and short example of combinding ResponseUtils
1 parent 6d27f1b commit 89e4e4b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ mock.mock(
4949
),
5050
ResponseUtils.delayed(1000, { data: 'lots of data' })
5151
);
52+
53+
// Combining resultsUtils
54+
mock.get('/test/:id', ResponseUtils.delayed(1000, (args: HandlerArgument) => {
55+
return ResponseUtils.jsonPromise({ requestId: args.pathParams.id });
56+
}));
5257
```
5358

5459
#### Types

test/yet-another-fetch-mock.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ describe('FetchMock', () => {
170170
});
171171
});
172172

173+
it('should supportd combinding delay and handlerargs', done => {
174+
mock.get(
175+
'/test/:id',
176+
ResponseUtils.delayed(1000, (args: HandlerArgument) => {
177+
return ResponseUtils.jsonPromise({ requestId: args.pathParams.id });
178+
})
179+
);
180+
181+
fetchToJson('/test/1234').then(json => {
182+
expect(json.requestId).toBe('1234');
183+
done();
184+
});
185+
});
186+
173187
it('should support responding with status codes', done => {
174188
mock.get('/error', ResponseUtils.statusCode(404));
175189

0 commit comments

Comments
 (0)