refactor: enhance error handling

This commit is contained in:
peaceiris 2019-09-21 02:47:29 +09:00
parent 67d5fb9f50
commit 8df3468b4d
4 changed files with 54 additions and 33 deletions

View file

@ -2,14 +2,23 @@ const getURL = require("../lib/get-url");
describe("getURL()", () => {
test("test", () => {
const baseURL = "https://github.com/gohugoio/hugo/releases/download/v0.58.2";
const baseURL =
"https://github.com/gohugoio/hugo/releases/download/v0.58.2";
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
expect(getURL("Linux", false, "0.58.2")).toBe(urlLinux);
expect(getURL("Linux", true, "0.58.2")).toBe(urlLinuxExtended);
expect(getURL("Linux", "false", "0.58.2")).toBe(urlLinux);
expect(getURL("Linux", "true", "0.58.2")).toBe(urlLinux);
expect(getURL("macOS", false, "0.58.2")).toBe(urlMacOS);
expect(getURL("Windows", false, "0.58.2")).toBe(urlWindows);
});
// test("test exception", () => {
// expect(() => {
// getURL("Linux", "hoge", "0.58.2");
// }).toThrowError("Invalid input (extended): hoge");
// });
});