Skip to content

Commit

Permalink
update url tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmy-zhening-luo committed Jan 25, 2025
1 parent 5b3fece commit dc427c6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/lib/object/url.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from "chai";
import url from "./url";
import Url from "./url";

const TEST = {
OK: "https://www.example.com/path/to/foo?a=1&b=2&c=3#fragment",
Expand All @@ -21,44 +21,44 @@ const TEST = {
},
},
},
parts = url(TEST.OK);
parts = new Url(TEST.OK);

describe("Object: URL", function () {
describe("shape", function () {
it("is a function", function () {
it("is a constructor", function () {
expect(url)
.a("function");
.a("constructor");
});
});
describe("throws", function () {
it("on nonsense", function () {
expect(() => url(TEST.ERROR))
expect(() => new Url(TEST.ERROR))
.throws();
});
it("HTTP host-less", function () {
expect(() => url(TEST.cases.throw.http))
expect(() => new Url(TEST.cases.throw.http))
.throws();
});
it("HTTP empty host", function () {
expect(() => url(TEST.cases.throw.httpEmpty))
expect(() => new Url(TEST.cases.throw.httpEmpty))
.throws();
});
it("HTTP localhost", function () {
expect(() => url(TEST.cases.throw.httpLocal))
expect(() => new Url(TEST.cases.throw.httpLocal))
.throws();
});
it("localhost", function () {
expect(() => url(TEST.cases.throw.local))
expect(() => new Url(TEST.cases.throw.local))
.throws();
});
it("and empty string", function () {
expect(() => url(TEST.cases.throw.empty))
expect(() => new Url(TEST.cases.throw.empty))
.throws();
});
it("but not on valid URLs", function () {
expect(() => url(TEST.OK))
expect(() => new Url(TEST.OK))
.does.not.throw();
expect(() => Object.values(TEST.cases.ok).map(u => url(u)))
expect(() => Object.values(TEST.cases.ok).map(u => new Url(u)))
.does.not.throw();
});
});
Expand Down

0 comments on commit dc427c6

Please sign in to comment.