Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
keaeriksson committed Jan 16, 2020
1 parent c79790b commit aaf9383
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mock-middleware.js
@@ -1,4 +1,4 @@
import { match, pathToRegexp } from 'path-to-regexp';
import { pathToRegexp } from 'path-to-regexp';
import { get } from 'lodash';

const mockMiddleware = options => async (req, res, next) => {
Expand All @@ -10,7 +10,7 @@ const mockMiddleware = options => async (req, res, next) => {
parsedPath.match(pathToRegexp(endpointToMatch.path))
);

if (!endpoint) return res.send(null);
if (!endpoint) return res.send({ message: 'Path not found' });

const validOperators = ['eq'];

Expand Down
20 changes: 20 additions & 0 deletions test/mock-middleware.unit.js
Expand Up @@ -241,4 +241,24 @@ describe('mock middleware unit tests', () => {
await request.get('/');
expect(loggerSpy.getCall(0).args[0]).to.match(/Invalid operator/);
});

it('should return empty response', async () => {
app.use(
mockMiddleware({
getConfiguration: async () => ({
parsedPath: '/',
configuration: {
endpoints: []
}
}),
logger
})
);
const request = supertest(app);
return request
.get('/')
.then(res =>
expect(res.body).to.have.property('message', 'Path not found')
);
});
});

0 comments on commit aaf9383

Please sign in to comment.