mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26:16 +01:00
fixed code smells and added some more tests
This commit is contained in:
@@ -10,6 +10,12 @@ describe("failure reducer", () => {
|
||||
expect(newState["FETCH_ITEMS"]).toBe(err);
|
||||
});
|
||||
|
||||
it("should do nothing for unknown action types", () => {
|
||||
const state = {};
|
||||
const newState = reducer(state, { type: "UNKNOWN" });
|
||||
expect(newState).toBe(state);
|
||||
});
|
||||
|
||||
it("should set the error for FETCH_ITEMS, if payload has multiple values", () => {
|
||||
const newState = reducer(
|
||||
{},
|
||||
@@ -52,6 +58,18 @@ describe("failure reducer", () => {
|
||||
expect(newState["FETCH_ITEMS"]).toBeFalsy();
|
||||
});
|
||||
|
||||
it("should reset FETCH_ITEMS after FETCH_ITEMS_RESET, but should not affect others", () => {
|
||||
const newState = reducer(
|
||||
{
|
||||
FETCH_ITEMS: err,
|
||||
FETCH_USERS: err
|
||||
},
|
||||
{ type: "FETCH_ITEMS_RESET" }
|
||||
);
|
||||
expect(newState["FETCH_ITEMS"]).toBeFalsy();
|
||||
expect(newState["FETCH_USERS"]).toBe(err);
|
||||
});
|
||||
|
||||
it("should set the error for a single item of FETCH_ITEM", () => {
|
||||
const newState = reducer(
|
||||
{},
|
||||
@@ -59,6 +77,14 @@ describe("failure reducer", () => {
|
||||
);
|
||||
expect(newState["FETCH_ITEM/42"]).toBe(err);
|
||||
});
|
||||
|
||||
it("should reset error for a single item of FETCH_ITEM", () => {
|
||||
const newState = reducer(
|
||||
{ "FETCH_ITEM/42": err },
|
||||
{ type: "FETCH_ITEM_SUCCESS", payload: err, itemId: 42 }
|
||||
);
|
||||
expect(newState["FETCH_ITEM/42"]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("failure selector", () => {
|
||||
|
||||
Reference in New Issue
Block a user