2021-10-09 00:12:56 +00:00
|
|
|
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)
|
|
|
|
|
2022-03-16 10:41:25 +00:00
|
|
|
let reqBody = null
|
|
|
|
|
2021-10-09 00:12:56 +00:00
|
|
|
flaska.get('/', function(ctx) {
|
|
|
|
ctx.body = { status: true }
|
|
|
|
})
|
2022-03-16 10:41:25 +00:00
|
|
|
flaska.post('/test', function(ctx) {
|
|
|
|
ctx.body = { success: true }
|
|
|
|
// console.log(ctx)
|
|
|
|
})
|
2021-10-09 00:12:56 +00:00
|
|
|
|
2022-03-16 10:41:25 +00:00
|
|
|
t.before(function() {
|
|
|
|
return flaska.listenAsync(port)
|
2021-10-09 00:12:56 +00:00
|
|
|
})
|
|
|
|
|
2022-03-16 10:41:25 +00:00
|
|
|
t.describe('/', function() {
|
|
|
|
t.test('should return status true', function() {
|
|
|
|
return client.get('/').then(function(body) {
|
2021-10-09 00:12:56 +00:00
|
|
|
assert.deepEqual(body, { status: true })
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2022-03-16 10:41:25 +00:00
|
|
|
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()
|
2021-10-09 00:12:56 +00:00
|
|
|
})
|