Skip to content

Commit fceca66

Browse files
committed
update tests to work with newer tap version
1 parent 44bceb8 commit fceca66

6 files changed

Lines changed: 19 additions & 30 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ node_modules/
66
.nyc_output/
77
.vscode/
88
examples/*/package-lock.json
9+
.tap/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"pre-commit": "npm run autofix && npm test",
4040
"lint": "eslint .",
4141
"autofix": "eslint . --fix",
42-
"test-spec": "tap --no-coverage test/*spec.js",
42+
"test-spec": "tap --allow-incomplete-coverage test/*spec.js",
4343
"test-perf": "node test/performance.js"
4444
},
4545
"license": "AGPL-3.0",

test/cookies_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test("should rewrite urls that change subdomain or protocol (but not domain)", f
108108
});
109109
data.stream = sourceStream;
110110
instance.handleResponse(data);
111-
t.notEqual(
111+
t.not(
112112
data.stream,
113113
sourceStream,
114114
"cookies.handleResponse should create a new stream to process content"
@@ -158,6 +158,6 @@ test("should work with SameSite attributes", function (t) {
158158
instance.handleResponse(data);
159159
var actual = data.headers["set-cookie"][0];
160160
console.log(actual);
161-
t.assert(actual.toLowerCase().indexOf("samesite=none") > -1);
161+
t.ok(actual.toLowerCase().indexOf("samesite=none") > -1);
162162
t.end();
163163
});

test/decompress_spec.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ test("should decompress data compressed with gzip", function (t) {
2424

2525
decompress(defaultConfig).handleResponse(data);
2626

27-
t.notEqual(
28-
source,
29-
data.stream,
30-
"it should create a new stream for decompression"
31-
);
27+
t.not(source, data.stream, "it should create a new stream for decompression");
3228

3329
t.notOk(
3430
data.headers["content-encoding"],
@@ -63,11 +59,7 @@ test("should decompress data compressed with deflate", function (t) {
6359

6460
decompress(defaultConfig).handleResponse(data);
6561

66-
t.notEqual(
67-
source,
68-
data.stream,
69-
"it should create a new stream for decompression"
70-
);
62+
t.not(source, data.stream, "it should create a new stream for decompression");
7163

7264
t.notOk(
7365
data.headers["content-encoding"],
@@ -129,11 +121,7 @@ test("should skip requests with no content, even if it can't tell ahead of time"
129121

130122
decompress(defaultConfig).handleResponse(data);
131123

132-
t.notEqual(
133-
source,
134-
data.stream,
135-
"it should create a new stream for decompression"
136-
);
124+
t.not(source, data.stream, "it should create a new stream for decompression");
137125

138126
data.stream.on("end", function () {
139127
t.end();

test/unblocker_spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test("url_rewriting should support support all kinds of links", function (t) {
1515
getServers(
1616
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
1717
function (err, servers) {
18-
t.ifErr(err);
18+
t.error(err);
1919
function cleanup() {
2020
servers.kill(function () {
2121
t.end();
@@ -43,7 +43,7 @@ test("should return control to parent when route doesn't match and no referer is
4343
getServers(
4444
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
4545
function (err, servers) {
46-
t.ifErr(err);
46+
t.error(err);
4747
function cleanup() {
4848
servers.kill(function () {
4949
t.end();
@@ -72,7 +72,7 @@ test("should redirect root-relative urls when the correct target can be determin
7272
getServers(
7373
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
7474
function (err, servers) {
75-
t.ifErr(err);
75+
t.error(err);
7676
function cleanup() {
7777
servers.kill(function () {
7878
t.end();
@@ -104,7 +104,7 @@ test("should redirect root-relative urls when the correct target can be determin
104104
getServers(
105105
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
106106
function (err, servers) {
107-
t.ifErr(err);
107+
t.error(err);
108108
function cleanup() {
109109
servers.kill(function () {
110110
t.end();
@@ -136,7 +136,7 @@ test("should NOT redirect http urls that have had the slashes merged (http:/ ins
136136
getServers(
137137
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
138138
function (err, servers) {
139-
t.ifErr(err);
139+
t.error(err);
140140
function cleanup() {
141141
servers.kill(function () {
142142
t.end();
@@ -159,7 +159,7 @@ test("should redirect http urls that have had the have two occurrences of /prefi
159159
getServers(
160160
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
161161
function (err, servers) {
162-
t.ifErr(err);
162+
t.error(err);
163163
function cleanup() {
164164
servers.kill(function () {
165165
t.end();
@@ -189,7 +189,7 @@ test("should redirect http urls that end in a TLD without a /", function (t) {
189189
getServers(
190190
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
191191
function (err, servers) {
192-
t.ifErr(err);
192+
t.error(err);
193193
function cleanup() {
194194
servers.kill(function () {
195195
t.end();
@@ -219,7 +219,7 @@ test("should redirect http urls that end in a TLD without a / when req.protocol
219219
const unblocker = new Unblocker({});
220220
app.use(unblocker);
221221
getServers({ app, unblocker, sourceContent }, function (err, servers) {
222-
t.ifErr(err);
222+
t.error(err);
223223
function cleanup() {
224224
servers.kill(function () {
225225
t.end();

test/websockets_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ test("it should pass text messages over a websocket connection", function (t) {
1515
const wss = new WebSocket.Server({ server: servers.remoteServer });
1616
wss.on("connection", function connection(ws) {
1717
ws.on("message", function incoming(message) {
18-
t.equal(message, "message from client");
18+
t.equal(message.toString(), "message from client");
1919
});
2020

2121
ws.send("message from server");
@@ -30,7 +30,7 @@ test("it should pass text messages over a websocket connection", function (t) {
3030
});
3131

3232
ws.on("message", function incoming(message) {
33-
t.equal(message, "message from server");
33+
t.equal(message.toString(), "message from server");
3434
ws.close();
3535
servers.kill(function () {
3636
t.end();
@@ -137,7 +137,7 @@ test("it should forward the path in a websocket requests", function (t) {
137137
t.ok(ws, "server connection event");
138138
ws.on("close", function (code, reason) {
139139
t.equal(code, 1008);
140-
t.equal(reason, "Policy Violation (sent from client)");
140+
t.equal(reason.toString(), "Policy Violation (sent from client)");
141141
servers.kill(function () {
142142
t.end();
143143
});
@@ -170,7 +170,7 @@ test("it should forward the path in a websocket requests", function (t) {
170170
const wsc = new WebSocket(wsurl.href);
171171
wsc.on("close", function (code, reason) {
172172
t.equal(code, 1008);
173-
t.equal(reason, "Policy Violation (sent from server)");
173+
t.equal(reason.toString(), "Policy Violation (sent from server)");
174174
servers.kill(function () {
175175
t.end();
176176
});

0 commit comments

Comments
 (0)