add basic reducer

This commit is contained in:
Maren Süwer
2018-08-23 09:10:23 +02:00
parent 4cc395bd73
commit 8d2bf3308e
2 changed files with 60 additions and 7 deletions

View File

@@ -2,8 +2,9 @@
import configureMockStore from "redux-mock-store";
import thunk from "redux-thunk";
import fetchMock from "fetch-mock";
import {
import reducer, {
fetchPermissions,
fetchPermissionsSuccess,
FETCH_PERMISSIONS_PENDING,
FETCH_PERMISSIONS_SUCCESS,
FETCH_PERMISSIONS_FAILURE
@@ -80,3 +81,26 @@ describe("permission fetch", () => {
});
});
});
describe("repos reducer", () => {
it("should return empty object, if state and action is undefined", () => {
expect(reducer()).toEqual({});
});
it("should return the same state, if the action is undefined", () => {
const state = { x: true };
expect(reducer(state)).toBe(state);
});
it("should return the same state, if the action is unknown to the reducer", () => {
const state = { x: true };
expect(reducer(state, { type: "EL_SPECIALE" })).toBe(state);
});
it("should store the permissions on FETCH_PERMISSION_SUCCESS", () => {
const newState = reducer(
{},
fetchPermissionsSuccess(s_bPermissions, "s", "b")
);
});
});