Skip to content

Commit

Permalink
feat: add missing tests (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinccbsg authored Apr 6, 2021
1 parent 48b5216 commit f05f6df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,15 @@
},
"dependencies": {
"openapi-validator-utils": "^1.0.1"
},
"jest": {
"collectCoverageFrom": [
"**/*.js",
"!**/*.config.js",
"!**/node_modules/**",
"!**/test/**",
"!**/coverage/**",
"!**/docs/**"
]
}
}
8 changes: 7 additions & 1 deletion test/fake-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ const serverApp = () => new Promise(resolve => {
* @param {array<Song>} request.body.required
* @return {object} 200 - song response
*/
app.post('/api/v1/albums', (req, res) => res.send('Hello World!'));
app.post('/api/v1/albums', validateMiddleware({
body: false,
params: false,
headers: false,
query: false,
required: false,
}), (req, res) => res.send('Hello World!'));

/**
* POST /api/v1/name
Expand Down
7 changes: 7 additions & 0 deletions test/request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,11 @@ describe('Body request tests', () => {
.send({ title: 'valid title' })
.expect(200)
));

it('should not throw error when middleware options are disabled', () => (
request
.post('/api/v1/albums')
.send({ title: 'valid title' })
.expect(200)
));
});

0 comments on commit f05f6df

Please sign in to comment.