Skip to content

Commit

Permalink
simplify fake route creation
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Aug 15, 2020
1 parent e85f5c0 commit e8de01c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions src/Route/index.js
Expand Up @@ -11,15 +11,13 @@ const isUrlMatcher = (matcher) =>
const isFunctionMatcher = (matcher) => typeof matcher === 'function';

class Route {
constructor(args, fetchMock, skipValidation = false) {
constructor(args, fetchMock) {
this.fetchMock = fetchMock;
const debug = getDebug('compileRoute()');
debug('Compiling route');
this.init(args);
this.sanitize();
if (!skipValidation) {
this.validate();
}
this.validate();
this.generateMatcher();
this.limit();
this.delayResponse();
Expand Down
8 changes: 4 additions & 4 deletions src/lib/inspecting.js
Expand Up @@ -6,10 +6,10 @@ const isName = (nameOrMatcher) =>
typeof nameOrMatcher === 'string' && /^[\da-zA-Z\-]+$/.test(nameOrMatcher);

const filterCallsWithMatcher = function (matcher, options = {}, calls) {
({ matcher } = new Route([Object.assign({ matcher }, options)], this, true));
// this.generateMatcher(
// this.sanitizeRoute()
// );
({ matcher } = new Route(
[Object.assign({ matcher, response: 'ok' }, options)],
this
));
return calls.filter(({ url, options }) =>
matcher(normalizeUrl(url), options)
);
Expand Down

0 comments on commit e8de01c

Please sign in to comment.