Skip to content

Commit

Permalink
refactor: simplify specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ninoseki committed Jul 1, 2019
1 parent bf1887b commit ec5f7c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
28 changes: 8 additions & 20 deletions src/spec/defang.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { defang } from "../index";

describe("defang", () => {
test("example.com", () => {
expect(defang("example.com")).toBe("example[.]com");
});

test("test.example.com", () => {
expect(defang("test.example.com")).toBe("test[.]example[.]com");
});

test("test@example.com", () => {
expect(defang("test@example.com")).toBe("test@example[.]com");
});

test("http://example.com", () => {
expect(defang("http://example.com")).toBe("hxxp://example[.]com");
});

test("https://example.com", () => {
expect(defang("https://example.com")).toBe("hxxps://example[.]com");
});
test("defang", () => {
expect(defang("example.com")).toBe("example[.]com");
expect(defang("test.example.com")).toBe("test[.]example[.]com");
expect(defang("test@example.com")).toBe("test@example[.]com");
expect(defang("http://example.com")).toBe("hxxp://example[.]com");
expect(defang("https://example.com")).toBe("hxxps://example[.]com");

expect(defang("example.none_tld")).toBe("example.none_tld");
});
28 changes: 8 additions & 20 deletions src/spec/refanc.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import { refang } from "../index";

describe("refang", () => {
test("example[.]com", () => {
expect(refang("example[.]com")).toBe("example.com");
});

test("test[.]example[.]com", () => {
expect(refang("test[.]example[.]com")).toBe("test.example.com");
});

test("test@example[.]com", () => {
expect(refang("test@example[.]com")).toBe("test@example.com");
});

test("hxxp://example[.]com", () => {
expect(refang("hxxp://example[.]com")).toBe("http://example.com");
});

test("hxxps://example[.]com", () => {
expect(refang("https://example[.]com")).toBe("https://example.com");
});
test("refang", () => {
expect(refang("example[.]com")).toBe("example.com");
expect(refang("test[.]example[.]com")).toBe("test.example.com");
expect(refang("test@example[.]com")).toBe("test@example.com");
expect(refang("hxxp://example[.]com")).toBe("http://example.com");
expect(refang("https://example[.]com")).toBe("https://example.com");

expect(refang("example.com")).toBe("example.com");
});

0 comments on commit ec5f7c5

Please sign in to comment.