diff --git a/src/app/credExplorer/RepositorySelect.js b/src/app/credExplorer/RepositorySelect.js index 60fc3e4..1f1ed92 100644 --- a/src/app/credExplorer/RepositorySelect.js +++ b/src/app/credExplorer/RepositorySelect.js @@ -89,6 +89,9 @@ function repoStringToRepo(x: string): Repo { export async function loadStatus(localStore: LocalStore): Promise { try { const response = await fetch(REPO_REGISTRY_API); + if (response.status === 404) { + return {type: "NO_REPOS"}; + } if (!response.ok) { console.error(response); return {type: "FAILURE"}; diff --git a/src/app/credExplorer/RepositorySelect.test.js b/src/app/credExplorer/RepositorySelect.test.js index 3bc1b75..ccc8e06 100644 --- a/src/app/credExplorer/RepositorySelect.test.js +++ b/src/app/credExplorer/RepositorySelect.test.js @@ -167,6 +167,13 @@ describe("app/credExplorer/RepositorySelect", () => { console.error = jest.fn(); }); }); + it("returns NO_REPOS on fetch 404", () => { + fetch.mockResponseOnce("irrelevant", {status: 404}); + expect.assertions(3); + return loadStatus(testLocalStore()).then((status) => { + expect(status).toEqual({type: "NO_REPOS"}); + }); + }); it("loads selectedRepo from localStore, if available", () => { const repos = [ {owner: "a", name: "b"},