-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
36 lines (32 loc) · 945 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import TestRunner from 'test-runner'
import assert from 'assert'
import Index from 'lws-index'
import Lws from 'lws'
import fetch from 'node-fetch'
const a = assert.strict
const tom = new TestRunner.Tom()
tom.test('no options', async function () {
const port = 9000 + this.index
const lws = await Lws.create({
stack: Index,
port: port
})
const response = await fetch(`http://localhost:${port}/`)
const body = await response.text()
lws.server.close()
a.ok(/listing directory/.test(body))
a.ok(/class="icon/.test(body))
})
tom.test('directory links have trailing slash', async function () {
const port = 9000 + this.index
const lws = await Lws.create({
stack: Index,
port: port
})
const response = await fetch(`http://localhost:${port}/`)
const body = await response.text()
lws.server.close()
a.ok(/href="\/node_modules\/"/.test(body))
a.ok(/href="\/index.js"/.test(body))
})
export default tom