Skip to content

Commit

Permalink
Moved sinon in dev dependencies, updated throttle tests with a 1000ms…
Browse files Browse the repository at this point in the history
… interval and added comments on sinon usage.
  • Loading branch information
jbigman committed Aug 3, 2023
1 parent 73d3732 commit f16c23a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/utils.throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ describe('Throttle tests', function () {
const url = 'https://yesno.wtf/api'; // Fake url used in this test, it could be anything.

it('Should make three requests with 1000ms interval. (Throttle function)', function () {
// If there is any http request with specified url, the http call will be handled by the fake server and return specified object
// This way we remove the dependance with any http api.
// If we don't want to rely on the availability of a particular api we can use mocks.
// The fake server intercept http calls and return specified objects if it mach the same method/url.
server.respondWith('GET', url, JSON.stringify({ test: 'this works' }));
const req = throttled(requestLib, {
limit: 1,
interval: 2000
interval: 1000
});
return Promise.all([req({ url }), req({ url }), req({ url })])
.then((response) => response.map(req => new Date(req.headers.date).getTime()))
Expand Down

0 comments on commit f16c23a

Please sign in to comment.