Skip to content

Commit

Permalink
fix route overwrite broken
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Oct 16, 2018
1 parent 76cc493 commit 0facdc4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/set-up-and-tear-down.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ FetchMock.mock = function(matcher, response, options = {}) {
};

const getMatcher = (route, propName) => route2 =>
route[propName] && route[propName] === route2[propName];
(!route[propName] && !route2[propName]) || (route[propName] === route2[propName]);

FetchMock.addRoute = function(uncompiledRoute) {
const route = this.compileRoute(uncompiledRoute);
Expand Down
3 changes: 1 addition & 2 deletions test/specs/routing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,13 @@ module.exports = fetchMock => {
expect(res.status).to.equal(300);
});

it('allow overwriting existing route #2', async () => {
it('overwrite correct route', async () => {
expect(() =>
fm
.mock('http://bar.co/', 200)
.mock('http://foo.co/', 400)
.mock('http://bar.co/', 300, { overwriteRoutes: true })
).not.to.throw();

const res = await fm.fetchHandler('http://foo.co/');
expect(res.status).to.equal(400);
});
Expand Down

0 comments on commit 0facdc4

Please sign in to comment.