Skip to content

Commit

Permalink
update tests to work with newer tap version
Browse files Browse the repository at this point in the history
  • Loading branch information
nfriedly committed Nov 16, 2023
1 parent 44bceb8 commit fceca66
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
.nyc_output/
.vscode/
examples/*/package-lock.json
.tap/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"pre-commit": "npm run autofix && npm test",
"lint": "eslint .",
"autofix": "eslint . --fix",
"test-spec": "tap --no-coverage test/*spec.js",
"test-spec": "tap --allow-incomplete-coverage test/*spec.js",
"test-perf": "node test/performance.js"
},
"license": "AGPL-3.0",
Expand Down
4 changes: 2 additions & 2 deletions test/cookies_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test("should rewrite urls that change subdomain or protocol (but not domain)", f
});
data.stream = sourceStream;
instance.handleResponse(data);
t.notEqual(
t.not(
data.stream,
sourceStream,
"cookies.handleResponse should create a new stream to process content"
Expand Down Expand Up @@ -158,6 +158,6 @@ test("should work with SameSite attributes", function (t) {
instance.handleResponse(data);
var actual = data.headers["set-cookie"][0];
console.log(actual);
t.assert(actual.toLowerCase().indexOf("samesite=none") > -1);
t.ok(actual.toLowerCase().indexOf("samesite=none") > -1);
t.end();
});
18 changes: 3 additions & 15 deletions test/decompress_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ test("should decompress data compressed with gzip", function (t) {

decompress(defaultConfig).handleResponse(data);

t.notEqual(
source,
data.stream,
"it should create a new stream for decompression"
);
t.not(source, data.stream, "it should create a new stream for decompression");

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

decompress(defaultConfig).handleResponse(data);

t.notEqual(
source,
data.stream,
"it should create a new stream for decompression"
);
t.not(source, data.stream, "it should create a new stream for decompression");

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

decompress(defaultConfig).handleResponse(data);

t.notEqual(
source,
data.stream,
"it should create a new stream for decompression"
);
t.not(source, data.stream, "it should create a new stream for decompression");

data.stream.on("end", function () {
t.end();
Expand Down
16 changes: 8 additions & 8 deletions test/unblocker_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test("url_rewriting should support support all kinds of links", function (t) {
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -43,7 +43,7 @@ test("should return control to parent when route doesn't match and no referer is
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -72,7 +72,7 @@ test("should redirect root-relative urls when the correct target can be determin
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -104,7 +104,7 @@ test("should redirect root-relative urls when the correct target can be determin
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -136,7 +136,7 @@ test("should NOT redirect http urls that have had the slashes merged (http:/ ins
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand All @@ -159,7 +159,7 @@ test("should redirect http urls that have had the have two occurrences of /prefi
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -189,7 +189,7 @@ test("should redirect http urls that end in a TLD without a /", function (t) {
getServers(
{ unblocker: new Unblocker({ clientScripts: false }), sourceContent },
function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -219,7 +219,7 @@ test("should redirect http urls that end in a TLD without a / when req.protocol
const unblocker = new Unblocker({});
app.use(unblocker);
getServers({ app, unblocker, sourceContent }, function (err, servers) {
t.ifErr(err);
t.error(err);
function cleanup() {
servers.kill(function () {
t.end();
Expand Down
8 changes: 4 additions & 4 deletions test/websockets_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test("it should pass text messages over a websocket connection", function (t) {
const wss = new WebSocket.Server({ server: servers.remoteServer });
wss.on("connection", function connection(ws) {
ws.on("message", function incoming(message) {
t.equal(message, "message from client");
t.equal(message.toString(), "message from client");
});

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

ws.on("message", function incoming(message) {
t.equal(message, "message from server");
t.equal(message.toString(), "message from server");
ws.close();
servers.kill(function () {
t.end();
Expand Down Expand Up @@ -137,7 +137,7 @@ test("it should forward the path in a websocket requests", function (t) {
t.ok(ws, "server connection event");
ws.on("close", function (code, reason) {
t.equal(code, 1008);
t.equal(reason, "Policy Violation (sent from client)");
t.equal(reason.toString(), "Policy Violation (sent from client)");
servers.kill(function () {
t.end();
});
Expand Down Expand Up @@ -170,7 +170,7 @@ test("it should forward the path in a websocket requests", function (t) {
const wsc = new WebSocket(wsurl.href);
wsc.on("close", function (code, reason) {
t.equal(code, 1008);
t.equal(reason, "Policy Violation (sent from server)");
t.equal(reason.toString(), "Policy Violation (sent from server)");
servers.kill(function () {
t.end();
});
Expand Down

0 comments on commit fceca66

Please sign in to comment.