|
| 1 | +import { shouldPassThrough } from "../src/server/http-combo-server"; |
| 2 | +import { expect } from "./test-utils"; |
| 3 | + |
| 4 | +describe("shouldPassThrough", () => { |
| 5 | + it("should return false when passThroughHostnames is empty and interceptOnlyHostnames is undefined", async () => { |
| 6 | + const should = shouldPassThrough("example.org", [], undefined); |
| 7 | + expect(should).to.be.false; |
| 8 | + }); |
| 9 | + |
| 10 | + it("should return true when both lists empty", async () => { |
| 11 | + const should = shouldPassThrough("example.org", [], []); |
| 12 | + expect(should).to.be.true; |
| 13 | + }); |
| 14 | + |
| 15 | + it("should return false when hostname is falsy", () => { |
| 16 | + const should = shouldPassThrough("", [], []); |
| 17 | + expect(should).to.be.false; |
| 18 | + }); |
| 19 | + |
| 20 | + describe("passThroughHostnames", () => { |
| 21 | + it("should return true when hostname is in passThroughHostnames", () => { |
| 22 | + const should = shouldPassThrough( |
| 23 | + "example.org", |
| 24 | + ["example.org"], |
| 25 | + undefined |
| 26 | + ); |
| 27 | + expect(should).to.be.true; |
| 28 | + }); |
| 29 | + |
| 30 | + it("should return false when hostname is not in passThroughHostnames", () => { |
| 31 | + const should = shouldPassThrough( |
| 32 | + "example.org", |
| 33 | + ["example.com"], |
| 34 | + undefined |
| 35 | + ); |
| 36 | + expect(should).to.be.false; |
| 37 | + }); |
| 38 | + }); |
| 39 | + describe("interceptOnlyHostnames", () => { |
| 40 | + it("should return false when hostname is in interceptOnlyHostnames", () => { |
| 41 | + const should = shouldPassThrough("example.org", [], ["example.org"]); |
| 42 | + expect(should).to.be.false; |
| 43 | + }); |
| 44 | + |
| 45 | + it("should return true when hostname is not in interceptOnlyHostnames", () => { |
| 46 | + const should = shouldPassThrough("example.org", [], ["example.com"]); |
| 47 | + expect(should).to.be.true; |
| 48 | + }); |
| 49 | + }); |
| 50 | +}); |
0 commit comments