RepositorySelect displays NO_REPOS on 404 (#547)
Test plan: Unit tests included, plus I manually tested it.
This commit is contained in:
parent
0b0815eb12
commit
e669e89315
|
@ -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"};
|
||||
|
|
|
@ -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"},
|
||||
|
|
Loading…
Reference in New Issue