Jonatan Nilsson
9c43b429c4
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded
flaska: Add promise-based listen and close methods
41 lines
899 B
JavaScript
41 lines
899 B
JavaScript
import { Eltro as t, assert} from 'eltro'
|
|
import { Flaska } from '../flaska.mjs'
|
|
import Client from './client.mjs'
|
|
|
|
const port = 51024
|
|
const flaska = new Flaska({})
|
|
const client = new Client(port)
|
|
|
|
let reqBody = null
|
|
|
|
flaska.get('/', function(ctx) {
|
|
ctx.body = { status: true }
|
|
})
|
|
flaska.post('/test', function(ctx) {
|
|
ctx.body = { success: true }
|
|
// console.log(ctx)
|
|
})
|
|
|
|
t.before(function() {
|
|
return flaska.listenAsync(port)
|
|
})
|
|
|
|
t.describe('/', function() {
|
|
t.test('should return status true', function() {
|
|
return client.get('/').then(function(body) {
|
|
assert.deepEqual(body, { status: true })
|
|
})
|
|
})
|
|
})
|
|
|
|
t.describe('/test', function() {
|
|
t.test('should return success and store body', async function() {
|
|
reqBody = null
|
|
let body = await client.post('/test')
|
|
assert.deepEqual(body, { success: true })
|
|
})
|
|
})
|
|
|
|
t.after(function() {
|
|
return flaska.closeAsync()
|
|
})
|