import { Eltro as t, assert} from 'eltro' import { createClient, server, resetLog } from './helper.server.mjs' t.describe('Server', function() { let client t.before(function() { client = createClient() }) t.test('should run', async function() { resetLog() assert.strictEqual(server.log.info.callCount, 0) let data = await client.get('/') assert.ok(data) assert.ok(data.name) assert.ok(data.version) assert.strictEqual(server.log.info.callCount, 1) assert.strictEqual(server.log.info.lastCall[0].status, 200) assert.strictEqual(server.log.info.lastCall[0].path, '/') assert.strictEqual(typeof(server.log.info.lastCall[0].ms), 'number') }) t.test('should handle errors fine', async function() { resetLog() assert.strictEqual(server.log.warn.callCount, 0) let data = await assert.isRejected(client.get('/error')) assert.ok(data) assert.ok(data.body) assert.strictEqual(data.body.status, 500) assert.match(data.body.message, /test/) assert.strictEqual(server.log.warn.callCount, 1) assert.strictEqual(server.log.warn.lastCall[0].status, 500) assert.strictEqual(server.log.warn.lastCall[0].path, '/error') assert.strictEqual(typeof(server.log.warn.lastCall[0].ms), 'number') }) })