Skip to content

Commit

Permalink
Merge pull request #562 from wheresrhys/all-done
Browse files Browse the repository at this point in the history
fix bug with detecting if done when mocking with *
  • Loading branch information
wheresrhys committed May 21, 2020
2 parents 17f940a + 6cea692 commit fe4e01d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/inspecting.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ FetchMock.filterCalls = function (nameOrMatcher, options) {
);
calls = calls.filter(({ identifier }) => identifier === nameOrMatcher);
} else {
matcher = normalizeUrl(nameOrMatcher);
matcher = nameOrMatcher === '*' ? '*' : normalizeUrl(nameOrMatcher);
if (this.routes.some(({ identifier }) => identifier === matcher)) {
debug(
`Filter provided, ${nameOrMatcher}, identifies a route. Returning only calls handled by that route`
Expand Down
12 changes: 12 additions & 0 deletions test/specs/repeat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ describe('repeat and done()', () => {
expect(fm.done('http://c.com/')).to.be.false;
});

it("can tell when done if using '*'", () => {
fm.mock('*', '200');
fm.fetchHandler('http://a.com');
expect(fm.done()).to.be.true;
});

it('can tell when done if using begin:', () => {
fm.mock('begin:http', '200');
fm.fetchHandler('http://a.com');
expect(fm.done()).to.be.true;
});

it("won't mock if route already matched enough times", async () => {
fm.mock('http://a.com/', 200, { repeat: 1 });

Expand Down

0 comments on commit fe4e01d

Please sign in to comment.