diff --git a/src/lib/compile-route.js b/src/lib/compile-route.js index f1a37a72..d3dc32c6 100644 --- a/src/lib/compile-route.js +++ b/src/lib/compile-route.js @@ -1,7 +1,9 @@ const generateMatcher = require('./generate-matcher'); - -const isUrlMatcher = matcher => matcher instanceof RegExp || typeof matcher === 'string' || (typeof matcher === 'object' && 'href' in matcher) +const isUrlMatcher = matcher => + matcher instanceof RegExp || + typeof matcher === 'string' || + (typeof matcher === 'object' && 'href' in matcher); const sanitizeRoute = route => { route = Object.assign({}, route); @@ -10,7 +12,7 @@ const sanitizeRoute = route => { route.method = route.method.toLowerCase(); } if (isUrlMatcher(route.matcher)) { - route.url = route.matcher + route.url = route.matcher; delete route.matcher; } route.identifier = route.name || route.url; @@ -18,7 +20,15 @@ const sanitizeRoute = route => { return route; }; -const matcherTypes = ['query', 'method', 'headers', 'params', 'body', 'functionMatcher', 'url'] +const matcherTypes = [ + 'query', + 'method', + 'headers', + 'params', + 'body', + 'functionMatcher', + 'url' +]; const validateRoute = route => { if (!('response' in route)) { diff --git a/src/lib/generate-matcher.js b/src/lib/generate-matcher.js index 6161928a..baae61be 100644 --- a/src/lib/generate-matcher.js +++ b/src/lib/generate-matcher.js @@ -105,8 +105,7 @@ const getFullUrlMatcher = (route, matcherUrl, query) => { }; }; - -const getFunctionMatcher = ({functionMatcher}) => functionMatcher; +const getFunctionMatcher = ({ functionMatcher }) => functionMatcher; const getUrlMatcher = route => { const { url: matcherUrl, query } = route; diff --git a/src/lib/set-up-and-tear-down.js b/src/lib/set-up-and-tear-down.js index 9b6b6838..5fe058fb 100644 --- a/src/lib/set-up-and-tear-down.js +++ b/src/lib/set-up-and-tear-down.js @@ -1,16 +1,18 @@ const compileRoute = require('./compile-route'); const FetchMock = {}; -const isUrlMatcher = matcher => matcher instanceof RegExp || typeof matcher === 'string' || (typeof matcher === 'object' && 'href' in matcher) -const isFunctionMatcher = matcher => typeof matcher === 'function' +const isUrlMatcher = matcher => + matcher instanceof RegExp || + typeof matcher === 'string' || + (typeof matcher === 'object' && 'href' in matcher); const argsToRoute = args => { const [matcher, response, options = {}] = args; - const routeConfig = {} + const routeConfig = {}; if (isUrlMatcher(matcher) || typeof matcher === 'function') { - routeConfig.matcher = matcher + routeConfig.matcher = matcher; } else { Object.assign(routeConfig, matcher); } @@ -19,7 +21,7 @@ const argsToRoute = args => { routeConfig.response = response; } - Object.assign(routeConfig, options) + Object.assign(routeConfig, options); return routeConfig; }; diff --git a/test/specs/set-up-and-tear-down.test.js b/test/specs/set-up-and-tear-down.test.js index 3c0847bf..b8908893 100644 --- a/test/specs/set-up-and-tear-down.test.js +++ b/test/specs/set-up-and-tear-down.test.js @@ -44,7 +44,7 @@ module.exports = fetchMock => { describe('parameters', () => { beforeEach(() => { - sinon.stub(fm, 'compileRoute').returns({}); + sinon.spy(fm, 'compileRoute'); sinon.stub(fm, '_mock').returns(fm); });