Adapt tests to new state layout

This commit is contained in:
Rene Pfeuffer
2019-12-17 13:34:28 +01:00
parent 45b989cd1a
commit 5ea149c262
2 changed files with 12 additions and 8 deletions

View File

@@ -127,7 +127,7 @@ describe("sources fetch", () => {
{ {
type: FETCH_SOURCES_SUCCESS, type: FETCH_SOURCES_SUCCESS,
itemId: "scm/core/_/", itemId: "scm/core/_/",
payload: collection payload: { updatePending: false, sources: collection }
} }
]; ];
@@ -148,7 +148,7 @@ describe("sources fetch", () => {
{ {
type: FETCH_SOURCES_SUCCESS, type: FETCH_SOURCES_SUCCESS,
itemId: "scm/core/abc/src", 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", () => { it("should store the collection, without revision and path", () => {
const expectedState = { const expectedState = {
"scm/core/_/": collection "scm/core/_/": { updatePending: false, sources: collection }
}; };
expect(reducer({}, fetchSourcesSuccess(repository, "", "", collection))).toEqual(expectedState); expect(reducer({}, fetchSourcesSuccess(repository, "", "", collection))).toEqual(expectedState);
}); });
it("should store the collection, with revision and path", () => { it("should store the collection, with revision and path", () => {
const expectedState = { 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); expect(reducer({}, fetchSourcesSuccess(repository, "abc", "src/main", collection))).toEqual(expectedState);
}); });
@@ -200,7 +200,7 @@ describe("selector tests", () => {
const state = { const state = {
sources: { sources: {
"scm/core/abc/src/main/package.json": { "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", () => { it("should return the source collection without revision and path", () => {
const state = { const state = {
sources: { sources: {
"scm/core/_/": collection "scm/core/_/": {
sources: collection
}
} }
}; };
expect(getSources(state, repository, "", "")).toBe(collection); expect(getSources(state, repository, "", "")).toBe(collection);
@@ -232,7 +234,9 @@ describe("selector tests", () => {
it("should return the source collection with revision and path", () => { it("should return the source collection with revision and path", () => {
const state = { const state = {
sources: { sources: {
"scm/core/abc/src/main": collection "scm/core/abc/src/main": {
sources: collection
}
} }
}; };
expect(getSources(state, repository, "abc", "src/main")).toBe(collection); expect(getSources(state, repository, "abc", "src/main")).toBe(collection);

View File

@@ -134,7 +134,7 @@ export function isFetchSourcesPending(state: any, repository: Repository, revisi
} }
function isUpdateSourcePending(state: any, repository: Repository, revision: string, path: string): boolean { 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( export function getFetchSourcesFailure(