|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | | -const { tspl } = require('@matteo.collina/tspl') |
4 | 3 | const { createServer } = require('node:http') |
5 | 4 | const { test, after } = require('node:test') |
6 | 5 | const { once } = require('node:events') |
7 | 6 | const examples = require('../docs/examples/request.js') |
8 | 7 |
|
9 | 8 | test('request examples', async (t) => { |
10 | | - t = tspl(t, { plan: 7 }) |
| 9 | + t.plan(7) |
11 | 10 |
|
12 | 11 | let lastReq |
13 | 12 | const exampleServer = createServer({ joinDuplicateHeaders: true }, (req, res) => { |
@@ -48,21 +47,19 @@ test('request examples', async (t) => { |
48 | 47 | ]) |
49 | 48 |
|
50 | 49 | await examples.getRequest(exampleServer.address().port) |
51 | | - t.strictEqual(lastReq.method, 'GET') |
| 50 | + t.assert.strictEqual(lastReq.method, 'GET') |
52 | 51 |
|
53 | 52 | await examples.postJSONRequest(exampleServer.address().port) |
54 | | - t.strictEqual(lastReq.method, 'POST') |
55 | | - t.strictEqual(lastReq.headers['content-type'], 'application/json') |
| 53 | + t.assert.strictEqual(lastReq.method, 'POST') |
| 54 | + t.assert.strictEqual(lastReq.headers['content-type'], 'application/json') |
56 | 55 |
|
57 | 56 | await examples.postFormRequest(exampleServer.address().port) |
58 | | - t.strictEqual(lastReq.method, 'POST') |
59 | | - t.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded') |
| 57 | + t.assert.strictEqual(lastReq.method, 'POST') |
| 58 | + t.assert.strictEqual(lastReq.headers['content-type'], 'application/x-www-form-urlencoded') |
60 | 59 |
|
61 | 60 | await examples.deleteRequest(exampleServer.address().port) |
62 | | - t.strictEqual(lastReq.method, 'DELETE') |
| 61 | + t.assert.strictEqual(lastReq.method, 'DELETE') |
63 | 62 |
|
64 | 63 | await examples.deleteRequest(errorServer.address().port) |
65 | | - t.strictEqual(lastReq.method, 'DELETE') |
66 | | - |
67 | | - await t.completed |
| 64 | + t.assert.strictEqual(lastReq.method, 'DELETE') |
68 | 65 | }) |
0 commit comments