♻️ Update eslint config (#1424)

This commit is contained in:
Luke Vella 2024-11-02 11:50:09 +00:00 committed by GitHub
parent 01396b6129
commit d55131c2ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
162 changed files with 337 additions and 266 deletions

View file

@ -0,0 +1,51 @@
import { absoluteUrl } from "./absolute-url";
describe("absoluteUrl", () => {
describe("when NEXT_PUBLIC_BASE_URL is set", () => {
beforeAll(() => {
process.env.NEXT_PUBLIC_BASE_URL = "https://example.com";
});
afterAll(() => {
delete process.env.NEXT_PUBLIC_BASE_URL;
});
it("should return the value of NEXT_PUBLIC_BASE_URL", () => {
expect(absoluteUrl()).toBe("https://example.com");
});
it("should return the correct absolute URL with query params", () => {
expect(absoluteUrl("/", { test: "test" })).toBe(
"https://example.com/?test=test",
);
});
it("should return the correct absolute URL with a subpath and query params", () => {
expect(absoluteUrl("/test", { test: "test" })).toBe(
"https://example.com/test?test=test",
);
});
});
describe("when NEXT_PUBLIC_BASE_URL is not set", () => {
it("should return the correct absolute URL with a subpath and query params", () => {
expect(absoluteUrl("/test", { test: "test" })).toBe(
"http://localhost:3000/test?test=test",
);
});
describe("when NEXT_PUBLIC_VERCEL_URL is set", () => {
beforeAll(() => {
process.env.NEXT_PUBLIC_VERCEL_URL = "example.vercel.com";
});
afterAll(() => {
delete process.env.NEXT_PUBLIC_VERCEL_URL;
});
it("should return the correct absolute URL with a subpath and query params", () => {
expect(absoluteUrl("/test", { test: "test" })).toBe(
"https://example.vercel.com/test?test=test",
);
});
});
});
});