RepositorySelect displays NO_REPOS on 404 (#547)

Test plan: Unit tests included, plus I manually tested it.
This commit is contained in:
Dandelion Mané 2018-07-27 15:47:15 -07:00 committed by GitHub
parent 0b0815eb12
commit e669e89315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -89,6 +89,9 @@ function repoStringToRepo(x: string): Repo {
export async function loadStatus(localStore: LocalStore): Promise<Status> {
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"};

View File

@ -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"},