Skip to content

Commit 2e47664

Browse files
committed
test: add test for application state
1 parent 31ea269 commit 2e47664

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

test/ignitor.spec.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* file that was distributed with this source code.
88
*/
99

10+
/// <reference path="../adonis-typings/index.ts" />
11+
1012
import { join } from 'path'
1113
import * as test from 'japa'
1214
import { createServer } from 'http'
@@ -260,7 +262,7 @@ test.group('Ignitor', (group) => {
260262
assert.isTrue(server.hookCalled)
261263
})
262264

263-
test('start http server to accept incoming requests', async (assert) => {
265+
test('start http server to accept incoming requests', async (assert, done) => {
264266
await fs.fsExtra.ensureDir(join(fs.basePath, 'config'))
265267
await fs.add('.adonisrc.json', JSON.stringify({
266268
autoloads: {
@@ -289,12 +291,17 @@ test.group('Ignitor', (group) => {
289291
ignitor.application.container.use('Adonis/Core/Route').get('/', () => 'handled')
290292

291293
await ignitor.startHttpServer((handler) => createServer(handler))
292-
const server = ignitor.application.container.use('Adonis/Core/Server')
294+
assert.isTrue(ignitor.application.isReady)
293295

296+
const server = ignitor.application.container.use('Adonis/Core/Server')
294297
const { text } = await supertest(server.instance).get('/').expect(200)
295298
server.instance.close()
296299

297-
assert.equal(text, 'handled')
300+
setTimeout(() => {
301+
assert.isFalse(ignitor.application.isReady)
302+
assert.equal(text, 'handled')
303+
done()
304+
}, 100)
298305
})
299306

300307
test('forward errors to app error handler', async (assert) => {

0 commit comments

Comments
 (0)