Files
hiring-test-one/test/api.js

19 lines
504 B
JavaScript
Raw Normal View History

2019-05-23 22:08:37 +01:00
const Tom = require('test-runner').Tom
const fetch = require('node-fetch')
2016-06-29 22:40:34 +01:00
const LocalWebServer = require('../')
2017-03-21 23:46:53 +00:00
const a = require('assert')
2016-06-29 22:40:34 +01:00
const tom = module.exports = new Tom('api')
2016-06-29 22:40:34 +01:00
2019-05-23 22:08:37 +01:00
tom.test('basic', async function () {
2017-03-21 23:46:53 +00:00
const port = 9000 + this.index
2019-06-02 23:15:15 +01:00
const ws = LocalWebServer.create({
2017-03-21 23:46:53 +00:00
port: port,
2017-06-25 19:21:38 +01:00
directory: 'test/fixture'
2016-06-29 22:40:34 +01:00
})
2019-05-23 22:08:37 +01:00
const response = await fetch(`http://localhost:${port}/one.txt`)
2019-06-02 23:15:15 +01:00
ws.server.close()
2019-05-23 22:08:37 +01:00
const body = await response.text()
a.strictEqual(body, 'one\n')
2016-06-29 22:40:34 +01:00
})