-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(generator): do not use example values if the useExampleValues opt…
…ion is set to false
- Loading branch information
1 parent
b769694
commit 953af41
Showing
3 changed files
with
48 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import path from 'path'; | ||
|
||
import express from 'express'; | ||
|
||
import { createMockMiddleware } from '../../src'; | ||
|
||
const app = express(); | ||
|
||
const middleware = createMockMiddleware({ | ||
spec: path.resolve(__dirname, '../fixtures/petstore.yaml'), | ||
options: { | ||
useExamplesValue: false, | ||
}, | ||
}); | ||
|
||
app.use('/api', middleware); | ||
|
||
export default app; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import supertest from 'supertest'; | ||
|
||
import app from './helpers/app-no-examples'; | ||
|
||
const request = supertest(app); | ||
|
||
describe('middleware', () => { | ||
it('should not use example values if useExamplesValue is set to false', async () => { | ||
const response = await request.get('/api/pet/2').set('api_key', 'someKey'); | ||
|
||
expect(response.status).toBe(200); | ||
expect(response.body).not.toHaveProperty('name', 'doggie'); | ||
expect(response.body).not.toHaveProperty('photoUrls', [ | ||
'http://test.test', | ||
'http://test1.test1', | ||
]); | ||
}); | ||
}); |