const request = require('supertest'); const mitama = require('../lib/index.js'); const Application = mitama.Application; const fs = require('fs'); describe('application', () => { it('should inherit from event emitter', done => { const app = new Application(); app.on('foo', done); app.emit('foo'); }); it('should have express instance', () => { const app = new Application(); app.get('/', (req, res, next) => { res.send('ok'); }); return request(app.express) .get('/') .expect('ok'); }); it('should be refered from request and response', () => { const app = new Application(); app.get('/', (req, res, next) => { if(req.mitamaApp instanceof Application) { res.sendStatus(200) }else{ res.sendStatus(500) } }); return request(app.express) .get('/') .expect(200); }); it('should be able to migrate database', () => { const app = new Application(); app.entities = []; app.resourcePath = `${__dirname}/`; app.migrate(); }); afterAll(() => { fs.remove(`${__dirname}/db.sqlite3}`); }); });