mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-14 14:46:30 +00:00
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> {
|
export async function loadStatus(localStore: LocalStore): Promise<Status> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(REPO_REGISTRY_API);
|
const response = await fetch(REPO_REGISTRY_API);
|
||||||
|
if (response.status === 404) {
|
||||||
|
return {type: "NO_REPOS"};
|
||||||
|
}
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error(response);
|
console.error(response);
|
||||||
return {type: "FAILURE"};
|
return {type: "FAILURE"};
|
||||||
|
@ -167,6 +167,13 @@ describe("app/credExplorer/RepositorySelect", () => {
|
|||||||
console.error = jest.fn();
|
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", () => {
|
it("loads selectedRepo from localStore, if available", () => {
|
||||||
const repos = [
|
const repos = [
|
||||||
{owner: "a", name: "b"},
|
{owner: "a", name: "b"},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user