|
| 1 | +import { Environment } from '@orchejs/common'; |
| 2 | +import { expect } from 'chai'; |
| 3 | +import { ExpressEngine } from '../../lib/engines'; |
| 4 | +import { OrcheRestConfig, ExpressSettings, OrcheRestResult } from '../..'; |
| 5 | + |
| 6 | +describe('ExpressEngine', () => { |
| 7 | + describe('#loadServer', () => { |
| 8 | + it('Should load server without routes in debug mode and adding cors', async () => { |
| 9 | + const settings: ExpressSettings = { |
| 10 | + xPoweredBy: false, |
| 11 | + caseSentiveRouting: false, |
| 12 | + env: 'development' |
| 13 | + }; |
| 14 | + |
| 15 | + const config: OrcheRestConfig = { |
| 16 | + settings, |
| 17 | + baseDir: '/test/engines', |
| 18 | + debug: true, |
| 19 | + corsConfig: { |
| 20 | + methods: 'GET' |
| 21 | + }, |
| 22 | + path: 'orche-express-test', |
| 23 | + port: 5000, |
| 24 | + logOptions: { |
| 25 | + disableLog: true |
| 26 | + } |
| 27 | + }; |
| 28 | + |
| 29 | + const expressEngine: ExpressEngine = new ExpressEngine(config); |
| 30 | + const result: OrcheRestResult = await expressEngine.loadServer(); |
| 31 | + expect(result.server).to.be.not.undefined; |
| 32 | + }); |
| 33 | + |
| 34 | + it('Should load server without middlewares, cors and in production mode', async () => { |
| 35 | + const config: OrcheRestConfig = { |
| 36 | + baseDir: '/test/engines', |
| 37 | + debug: true, |
| 38 | + path: 'orche-express-test', |
| 39 | + port: 5001, |
| 40 | + environment: Environment.Production, |
| 41 | + logOptions: { |
| 42 | + disableLog: true |
| 43 | + } |
| 44 | + }; |
| 45 | + |
| 46 | + const expressEngine: ExpressEngine = new ExpressEngine(config); |
| 47 | + const result: OrcheRestResult = await expressEngine.loadServer(); |
| 48 | + expect(result.server).to.be.not.undefined; |
| 49 | + }); |
| 50 | + }); |
| 51 | +}); |
0 commit comments