forked from fastify/fastify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunlock.test.js
42 lines (38 loc) · 959 Bytes
/
unlock.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
37
38
39
40
41
42
'use strict'
const { test } = require('node:test')
const sget = require('simple-get').concat
const fastify = require('../../fastify')()
fastify.addHttpMethod('UNLOCK')
test('can be created - unlock', t => {
t.plan(1)
try {
fastify.route({
method: 'UNLOCK',
url: '*',
handler: function (req, reply) {
reply.code(204).send()
}
})
t.assert.ok(true)
} catch (e) {
t.assert.fail()
}
})
test('unlock test', async t => {
await fastify.listen({ port: 0 })
t.after(() => { fastify.close() })
await t.test('request - unlock', (t, done) => {
t.plan(2)
sget({
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
method: 'UNLOCK',
headers: {
'Lock-Token': 'urn:uuid:a515cfa4-5da4-22e1-f5b5-00a0451e6bf7'
}
}, (err, response, body) => {
t.assert.ifError(err)
t.assert.strictEqual(response.statusCode, 204)
done()
})
})
})