Skip to content

Commit 99c61f3

Browse files
authored
test: migrate to node:test (#93)
1 parent d9c2e81 commit 99c61f3

File tree

6 files changed

+131
-205
lines changed

6 files changed

+131
-205
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"c8": "^10.1.2",
6262
"eslint": "^9.17.0",
6363
"neostandard": "^0.12.0",
64-
"tape": "^5.7.5",
6564
"tsd": "^0.32.0"
6665
},
6766
"scripts": {
@@ -70,6 +69,6 @@
7069
"lint:fix": "eslint --fix",
7170
"test": "npm run test:unit && npm run test:typescript",
7271
"test:typescript": "tsd",
73-
"test:unit": "c8 tape test/**/*.js"
72+
"test:unit": "c8 --100 node --test"
7473
}
7574
}

test/.eslintrc.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

test/all.js renamed to test/all.test.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,48 @@
11
'use strict'
22

3-
const test = require('tape')
3+
const { test } = require('node:test')
44
const proxyaddr = require('..')
55

66
test('argument req should be required', function (t) {
7-
t.throws(proxyaddr.all, /req.*required/u)
8-
t.end()
7+
t.assert.throws(proxyaddr.all, /req.*required/u)
98
})
109

1110
test('argument trustshould be optional', function (t) {
1211
const req = createReq('127.0.0.1')
13-
t.doesNotThrow(proxyaddr.all.bind(null, req))
14-
t.end()
12+
t.assert.doesNotThrow(proxyaddr.all.bind(null, req))
1513
})
1614

1715
test('with no headers should return socket address', function (t) {
1816
const req = createReq('127.0.0.1')
19-
t.same(proxyaddr.all(req), ['127.0.0.1'])
20-
t.end()
17+
t.assert.deepStrictEqual(proxyaddr.all(req), ['127.0.0.1'])
2118
})
2219

2320
test('with x-forwarded-for header should include x-forwarded-for', function (t) {
2421
const req = createReq('127.0.0.1', {
2522
'x-forwarded-for': '10.0.0.1'
2623
})
27-
t.same(proxyaddr.all(req), ['127.0.0.1', '10.0.0.1'])
28-
t.end()
24+
t.assert.deepStrictEqual(proxyaddr.all(req), ['127.0.0.1', '10.0.0.1'])
2925
})
3026

3127
test('with x-forwarded-for header should include x-forwarded-for in correct order', function (t) {
3228
const req = createReq('127.0.0.1', {
3329
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
3430
})
35-
t.same(proxyaddr.all(req), ['127.0.0.1', '10.0.0.2', '10.0.0.1'])
36-
t.end()
31+
t.assert.deepStrictEqual(proxyaddr.all(req), ['127.0.0.1', '10.0.0.2', '10.0.0.1'])
3732
})
3833

3934
test('with trust argument should stop at first untrusted', function (t) {
4035
const req = createReq('127.0.0.1', {
4136
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
4237
})
43-
t.same(proxyaddr.all(req, '127.0.0.1'), ['127.0.0.1', '10.0.0.2'])
44-
t.end()
38+
t.assert.deepStrictEqual(proxyaddr.all(req, '127.0.0.1'), ['127.0.0.1', '10.0.0.2'])
4539
})
4640

4741
test('with trust argument should be only socket address for no trust', function (t) {
4842
const req = createReq('127.0.0.1', {
4943
'x-forwarded-for': '10.0.0.1, 10.0.0.2'
5044
})
51-
t.same(proxyaddr.all(req, []), ['127.0.0.1'])
52-
t.end()
45+
t.assert.deepStrictEqual(proxyaddr.all(req, []), ['127.0.0.1'])
5346
})
5447

5548
function createReq (socketAddr, headers) {

0 commit comments

Comments
 (0)