Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions __test__/DownloadURL.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { describe, expect, test } from "vitest";
import { ArchiveDownloadURL, LatestDownloadURL } from "../src/DownloadURL";
import { UnsupportedPlatformError } from "../src/errors";
import { Arch, OS } from "../src/platform";
import { LatestVersion } from "../src/versions";

describe("ArchiveDownloadURL", () => {
describe.each([
[
{ os: OS.LINUX, arch: Arch.I686 },
"https://ftp.mozilla.org/pub/firefox/releases/134.0/linux-i686/en-US/firefox-134.0.tar.bz2",
],
[
{ os: OS.LINUX, arch: Arch.AMD64 },
"https://ftp.mozilla.org/pub/firefox/releases/134.0/linux-x86_64/en-US/firefox-134.0.tar.bz2",
Expand All @@ -22,10 +17,6 @@ describe("ArchiveDownloadURL", () => {
{ os: OS.MACOS, arch: Arch.AMD64 },
"https://ftp.mozilla.org/pub/firefox/releases/134.0/mac/en-US/Firefox%20134.0.dmg",
],
[
{ os: OS.WINDOWS, arch: Arch.I686 },
"https://ftp.mozilla.org/pub/firefox/releases/134.0/win32/en-US/Firefox%20Setup%20134.0.exe",
],
[
{ os: OS.WINDOWS, arch: Arch.AMD64 },
"https://ftp.mozilla.org/pub/firefox/releases/134.0/win64/en-US/Firefox%20Setup%20134.0.exe",
Expand All @@ -42,10 +33,6 @@ describe("ArchiveDownloadURL", () => {
});

describe.each([
[
{ version: "firefox-80.0", os: OS.LINUX, arch: Arch.I686 },
"https://ftp.mozilla.org/pub/firefox/releases/80.0/linux-i686/en-US/firefox-80.0.tar.bz2",
],
[
{ version: "devedition-135.0b1", os: OS.LINUX, arch: Arch.AMD64 },
"https://ftp.mozilla.org/pub/devedition/releases/135.0b1/linux-x86_64/en-US/firefox-135.0b1.tar.xz",
Expand All @@ -60,22 +47,10 @@ describe("ArchiveDownloadURL", () => {
expect(sut.getURL()).toEqual(expected);
});
});

describe.each([[OS.MACOS, Arch.I686]])("platform %s %s", (os, arch) => {
test("throws an error", () => {
const sut = new ArchiveDownloadURL("80.0", { os, arch }, "en-US");
expect(() => sut.getURL()).toThrowError(UnsupportedPlatformError);
});
});
});

describe("LatestDownloadURL", () => {
describe.each([
[
LatestVersion.LATEST,
{ os: OS.LINUX, arch: Arch.I686 },
"https://download.mozilla.org/?product=firefox-latest&os=linux&lang=en-US",
],
[
LatestVersion.LATEST,
{ os: OS.LINUX, arch: Arch.AMD64 },
Expand Down Expand Up @@ -106,11 +81,6 @@ describe("LatestDownloadURL", () => {
{ os: OS.MACOS, arch: Arch.ARM64 },
"https://download.mozilla.org/?product=firefox-esr-latest&os=osx&lang=en-US",
],
[
LatestVersion.LATEST_ESR,
{ os: OS.WINDOWS, arch: Arch.I686 },
"https://download.mozilla.org/?product=firefox-esr-latest&os=win&lang=en-US",
],
[
LatestVersion.LATEST_ESR,
{ os: OS.WINDOWS, arch: Arch.AMD64 },
Expand All @@ -127,15 +97,4 @@ describe("LatestDownloadURL", () => {
expect(sut.getURL()).toEqual(expected);
});
});

describe.each([[OS.MACOS, Arch.I686]])("platform %s %s", (os, arch) => {
test("throws an error", () => {
const sut = new LatestDownloadURL(
LatestVersion.LATEST,
{ os, arch },
"en-US",
);
expect(() => sut.getURL()).toThrowError(UnsupportedPlatformError);
});
});
});
8 changes: 0 additions & 8 deletions src/DownloadURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ export class ArchiveDownloadURL implements DownloadURL {
return "mac";
} else if (os === OS.MACOS && arch === Arch.ARM64) {
return "mac";
} else if (os === OS.LINUX && arch === Arch.I686) {
return "linux-i686";
} else if (os === OS.LINUX && arch === Arch.AMD64) {
return "linux-x86_64";
} else if (os === OS.LINUX && arch === Arch.ARM64) {
return "linux-aarch64";
} else if (os === OS.WINDOWS && arch === Arch.I686) {
return "win32";
} else if (os === OS.WINDOWS && arch === Arch.AMD64) {
return "win64";
} else if (os === OS.WINDOWS && arch === Arch.ARM64) {
Expand Down Expand Up @@ -118,14 +114,10 @@ export class LatestDownloadURL implements DownloadURL {
return "osx";
} else if (os === OS.MACOS && arch === Arch.ARM64) {
return "osx";
} else if (os === OS.LINUX && arch === Arch.I686) {
return "linux";
} else if (os === OS.LINUX && arch === Arch.AMD64) {
return "linux64";
} else if (os === OS.LINUX && arch === Arch.ARM64) {
return "linux64-aarch64";
} else if (os === OS.WINDOWS && arch === Arch.I686) {
return "win";
} else if (os === OS.WINDOWS && arch === Arch.AMD64) {
return "win64";
} else if (os === OS.WINDOWS && arch === Arch.ARM64) {
Expand Down
3 changes: 0 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type OS = (typeof OS)[keyof typeof OS];

export const Arch = {
AMD64: "amd64",
I686: "i686",
ARM64: "arm64",
} as const;

Expand All @@ -39,8 +38,6 @@ export const getArch = (): Arch => {
switch (arch) {
case "arm64":
return Arch.ARM64;
case "x32":
return Arch.I686;
case "x64":
return Arch.AMD64;
}
Expand Down
Loading