From 5ea149c2622b1d4f8c4f4c4932f0b88dc9198b7d Mon Sep 17 00:00:00 2001 From: Rene Pfeuffer Date: Tue, 17 Dec 2019 13:34:28 +0100 Subject: [PATCH] Adapt tests to new state layout --- .../src/repos/sources/modules/sources.test.ts | 18 +++++++++++------- .../src/repos/sources/modules/sources.ts | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scm-ui/ui-webapp/src/repos/sources/modules/sources.test.ts b/scm-ui/ui-webapp/src/repos/sources/modules/sources.test.ts index 55737f7ee0..fd676d7c57 100644 --- a/scm-ui/ui-webapp/src/repos/sources/modules/sources.test.ts +++ b/scm-ui/ui-webapp/src/repos/sources/modules/sources.test.ts @@ -127,7 +127,7 @@ describe("sources fetch", () => { { type: FETCH_SOURCES_SUCCESS, itemId: "scm/core/_/", - payload: collection + payload: { updatePending: false, sources: collection } } ]; @@ -148,7 +148,7 @@ describe("sources fetch", () => { { type: FETCH_SOURCES_SUCCESS, itemId: "scm/core/abc/src", - payload: collection + payload: { updatePending: false, sources: collection } } ]; @@ -182,14 +182,14 @@ describe("reducer tests", () => { it("should store the collection, without revision and path", () => { const expectedState = { - "scm/core/_/": collection + "scm/core/_/": { updatePending: false, sources: collection } }; expect(reducer({}, fetchSourcesSuccess(repository, "", "", collection))).toEqual(expectedState); }); it("should store the collection, with revision and path", () => { const expectedState = { - "scm/core/abc/src/main": collection + "scm/core/abc/src/main": { updatePending: false, sources: collection } }; expect(reducer({}, fetchSourcesSuccess(repository, "abc", "src/main", collection))).toEqual(expectedState); }); @@ -200,7 +200,7 @@ describe("selector tests", () => { const state = { sources: { "scm/core/abc/src/main/package.json": { - noDirectory + sources: {noDirectory} } } }; @@ -223,7 +223,9 @@ describe("selector tests", () => { it("should return the source collection without revision and path", () => { const state = { sources: { - "scm/core/_/": collection + "scm/core/_/": { + sources: collection + } } }; expect(getSources(state, repository, "", "")).toBe(collection); @@ -232,7 +234,9 @@ describe("selector tests", () => { it("should return the source collection with revision and path", () => { const state = { sources: { - "scm/core/abc/src/main": collection + "scm/core/abc/src/main": { + sources: collection + } } }; expect(getSources(state, repository, "abc", "src/main")).toBe(collection); diff --git a/scm-ui/ui-webapp/src/repos/sources/modules/sources.ts b/scm-ui/ui-webapp/src/repos/sources/modules/sources.ts index 8a04dcdc76..8abdec9fd5 100644 --- a/scm-ui/ui-webapp/src/repos/sources/modules/sources.ts +++ b/scm-ui/ui-webapp/src/repos/sources/modules/sources.ts @@ -134,7 +134,7 @@ export function isFetchSourcesPending(state: any, repository: Repository, revisi } function isUpdateSourcePending(state: any, repository: Repository, revision: string, path: string): boolean { - return state?.sources[createItemId(repository, revision, path)]?.updatePending; + return state?.sources && state.sources[createItemId(repository, revision, path)]?.updatePending; } export function getFetchSourcesFailure(