-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing default export function issue (#846)
Co-authored-by: Kesha Shah <keshashah@wolkus.com>
- Loading branch information
1 parent
9d215be
commit 268d38a
Showing
3 changed files
with
52 additions
and
1 deletion.
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,46 @@ | ||
import * as express from 'express'; | ||
import * as OpenApiValidator from '../src'; | ||
import { expect } from 'chai'; | ||
import * as request from 'supertest'; | ||
import * as path from 'path'; | ||
|
||
describe('default export resolver', () => { | ||
let server = null; | ||
let app = express(); | ||
|
||
before(async () => { | ||
app.use( | ||
OpenApiValidator.middleware({ | ||
apiSpec: { | ||
openapi: '3.0.0', | ||
info: { version: '1.0.0', title: 'test bug OpenApiValidator' }, | ||
paths: { | ||
'/': { | ||
get: { | ||
operationId: 'test#get', | ||
// @ts-ignore | ||
'x-eov-operation-handler': 'routes/default-export-fn', | ||
responses: { 200: { description: 'homepage' } } | ||
} | ||
}, | ||
}, | ||
}, | ||
operationHandlers: path.join(__dirname, 'resources'), | ||
}), | ||
); | ||
|
||
server = app.listen(3000); | ||
console.log('server start port 3000'); | ||
}); | ||
|
||
after(async () => server.close()); | ||
|
||
it('should use default export operation', async () => { | ||
return request(app) | ||
.get(`/`) | ||
.expect(200) | ||
.then((r) => { | ||
expect(r.body).to.have.property('message').that.equals("It Works!"); | ||
}); | ||
}); | ||
}); |
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,5 @@ | ||
exports.default = { | ||
'test#get': (req, res) => { | ||
res.status(200).json({ message: 'It Works!' }); | ||
}, | ||
}; |