diff --git a/.taprc b/.taprc deleted file mode 100644 index 30f3026..0000000 --- a/.taprc +++ /dev/null @@ -1,3 +0,0 @@ -show-full-coverage: true -plugin: - - "!@tapjs/typescript" diff --git a/package.json b/package.json index 55ee1ed..e3c5c5d 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "devDependencies": { "@types/node": "^22.0.0", "benchmark": "2.1.4", + "c8": "^10.1.2", "standard": "^17.1.0", - "tap": "^18.8.0", "tsd": "^0.31.1" }, "types": "types/index.d.ts", @@ -42,7 +42,7 @@ "lint": "standard", "lint:fix": "standard --fix", "test": "npm run test:unit && npm run test:typescript", - "test:unit": "tap", + "test:unit": "c8 node --test", "test:typescript": "tsd" } } diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 29c15b0..0000000 --- a/test/.eslintrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "env": { - "mocha": true - } -} diff --git a/test/test.js b/test/test.js index d2ff5ed..face3f9 100644 --- a/test/test.js +++ b/test/test.js @@ -1,17 +1,17 @@ 'use strict' -const { test } = require('tap') +const test = require('node:test') const forwarded = require('..') test('should require req', function (t) { t.plan(1) - t.throws(forwarded.bind(null), 'argument req.*required') + t.assert.throws(forwarded.bind(null), 'argument req.*required') }) test('should work with X-Forwarded-For header', function (t) { t.plan(1) const req = createReq('127.0.0.1') - t.same(forwarded(req), ['127.0.0.1']) + t.assert.deepStrictEqual(forwarded(req), ['127.0.0.1']) }) test('should include entries from X-Forwarded-For', function (t) { @@ -19,7 +19,11 @@ test('should include entries from X-Forwarded-For', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': '10.0.0.2, 10.0.0.1' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should include entries from X-Forwarded-For', function (t) { @@ -27,7 +31,7 @@ test('should include entries from X-Forwarded-For', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': ' ' }) - t.same(forwarded(req), ['127.0.0.1']) + t.assert.deepStrictEqual(forwarded(req), ['127.0.0.1']) }) test('should include entries from X-Forwarded-For', function (t) { @@ -35,7 +39,7 @@ test('should include entries from X-Forwarded-For', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': '10.0.0.1' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1']) + t.assert.deepStrictEqual(forwarded(req), ['127.0.0.1', '10.0.0.1']) }) test('should skip blank entries', function (t) { @@ -43,7 +47,11 @@ test('should skip blank entries', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': '10.0.0.2,, 10.0.0.1' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should trim leading OWS', function (t) { @@ -51,7 +59,11 @@ test('should trim leading OWS', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': ' 10.0.0.2 , , 10.0.0.1 ' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should handle correctly when beginning with a comma', function (t) { @@ -59,7 +71,11 @@ test('should handle correctly when beginning with a comma', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': ', 10.0.0.2 , , 10.0.0.1' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should handle correctly when ending with a comma', function (t) { @@ -67,7 +83,11 @@ test('should handle correctly when ending with a comma', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': '10.0.0.2 , , 10.0.0.1,' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should trim trailing OWS before a comma', function (t) { @@ -75,7 +95,11 @@ test('should trim trailing OWS before a comma', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': ' , 10.0.0.2 , , 10.0.0.1' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) test('should trim trailing OWS after a comma', function (t) { @@ -83,7 +107,11 @@ test('should trim trailing OWS after a comma', function (t) { const req = createReq('127.0.0.1', { 'x-forwarded-for': ' 10.0.0.2 , , 10.0.0.1 , ' }) - t.same(forwarded(req), ['127.0.0.1', '10.0.0.1', '10.0.0.2']) + t.assert.deepStrictEqual(forwarded(req), [ + '127.0.0.1', + '10.0.0.1', + '10.0.0.2' + ]) }) function createReq (socketAddr, headers) {