@thepalaceproject/circulation-admin 1.43.0-post.2 → 1.43.0-post.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +14 -12
- package/dist/circulation-admin.js +1 -1
- package/jest.config.js +48 -16
- package/package.json +4 -17
- package/tests/jest/editorAdapter.test.ts +245 -0
- package/tests/jest/legacy-setup.ts +13 -0
- package/tests/jest/legacyJsdomEnvironment.js +49 -0
- package/tests/jest/models/Admin.test.ts +206 -0
- package/tests/jest/reducers/bookCoverPreview.test.ts +81 -0
- package/tests/jest/reducers/classifications.test.ts +161 -0
- package/tests/jest/reducers/collections.test.ts +96 -0
- package/tests/jest/reducers/complaints.test.ts +166 -0
- package/tests/jest/reducers/createFetchEditReducer.test.ts +220 -0
- package/tests/jest/reducers/createRegisterLibraryReducer.test.ts +51 -0
- package/tests/jest/reducers/customListDetails.test.ts +120 -0
- package/tests/jest/reducers/customListEditor.test.ts +2823 -0
- package/tests/jest/reducers/managePatrons.test.ts +71 -0
- package/tests/jest/utils/sharedFunctions.test.ts +121 -0
- package/tsconfig.json +3 -4
- package/.nycrc.json +0 -8
- package/testReporter.js +0 -29
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import reducer, {
|
|
2
|
+
BookCoverPreviewState,
|
|
3
|
+
} from "../../../src/reducers/bookCoverPreview";
|
|
4
|
+
import ActionCreator from "../../../src/actions";
|
|
5
|
+
|
|
6
|
+
describe("book cover preview reducer", () => {
|
|
7
|
+
const preview = "image data";
|
|
8
|
+
|
|
9
|
+
const initState: BookCoverPreviewState = {
|
|
10
|
+
data: null,
|
|
11
|
+
isFetching: false,
|
|
12
|
+
fetchError: null,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const errorState: BookCoverPreviewState = {
|
|
16
|
+
data: null,
|
|
17
|
+
isFetching: false,
|
|
18
|
+
fetchError: { status: 401, response: "test error", url: "test url" },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const loadedState = Object.assign({}, initState, {
|
|
22
|
+
data: preview,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("returns initial state for unrecognized action", () => {
|
|
26
|
+
expect(reducer(undefined, {})).toStrictEqual(initState);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("handles PREVIEW_BOOK_COVER_REQUEST", () => {
|
|
30
|
+
const action = {
|
|
31
|
+
type: `${ActionCreator.PREVIEW_BOOK_COVER}_${ActionCreator.REQUEST}`,
|
|
32
|
+
url: "test url",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// start with empty state
|
|
36
|
+
let newState = Object.assign({}, initState, {
|
|
37
|
+
isFetching: true,
|
|
38
|
+
});
|
|
39
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
40
|
+
|
|
41
|
+
// start with error state
|
|
42
|
+
newState = Object.assign({}, errorState, {
|
|
43
|
+
isFetching: true,
|
|
44
|
+
fetchError: null,
|
|
45
|
+
});
|
|
46
|
+
expect(reducer(errorState, action)).toStrictEqual(newState);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("handles PREVIEW_BOOK_COVER_FAILURE", () => {
|
|
50
|
+
const action = {
|
|
51
|
+
type: `${ActionCreator.PREVIEW_BOOK_COVER}_${ActionCreator.FAILURE}`,
|
|
52
|
+
error: "test error",
|
|
53
|
+
};
|
|
54
|
+
const oldState = Object.assign({}, initState, { isFetching: true });
|
|
55
|
+
const newState = Object.assign({}, oldState, {
|
|
56
|
+
fetchError: "test error",
|
|
57
|
+
isFetching: false,
|
|
58
|
+
});
|
|
59
|
+
expect(reducer(oldState, action)).toStrictEqual(newState);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("handles PREVIEW_BOOK_COVER_LOAD", () => {
|
|
63
|
+
const action = {
|
|
64
|
+
type: `${ActionCreator.PREVIEW_BOOK_COVER}_${ActionCreator.LOAD}`,
|
|
65
|
+
data: preview,
|
|
66
|
+
};
|
|
67
|
+
const newState = Object.assign({}, initState, {
|
|
68
|
+
data: preview,
|
|
69
|
+
isFetching: false,
|
|
70
|
+
});
|
|
71
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("handles PREVIEW_BOOK_COVER_CLEAR", () => {
|
|
75
|
+
const action = {
|
|
76
|
+
type: `${ActionCreator.PREVIEW_BOOK_COVER}_${ActionCreator.CLEAR}`,
|
|
77
|
+
};
|
|
78
|
+
expect(reducer(loadedState, action)).toStrictEqual(initState);
|
|
79
|
+
expect(reducer(errorState, action)).toStrictEqual(initState);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import reducer, {
|
|
2
|
+
ClassificationsState,
|
|
3
|
+
} from "../../../src/reducers/classifications";
|
|
4
|
+
import ActionCreator from "../../../src/actions";
|
|
5
|
+
|
|
6
|
+
describe("classifications reducer", () => {
|
|
7
|
+
const genreData = {
|
|
8
|
+
Fiction: {},
|
|
9
|
+
Nonfiction: {},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const classificationsData = [
|
|
13
|
+
{
|
|
14
|
+
type: "type",
|
|
15
|
+
name: "name",
|
|
16
|
+
source: "source",
|
|
17
|
+
weight: "weight",
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const initState: ClassificationsState = {
|
|
22
|
+
genreTree: null,
|
|
23
|
+
classifications: null,
|
|
24
|
+
isFetchingGenreTree: false,
|
|
25
|
+
isEditingClassifications: false,
|
|
26
|
+
isFetchingClassifications: false,
|
|
27
|
+
fetchError: null,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const errorState: ClassificationsState = {
|
|
31
|
+
genreTree: null,
|
|
32
|
+
classifications: null,
|
|
33
|
+
isFetchingGenreTree: false,
|
|
34
|
+
isEditingClassifications: false,
|
|
35
|
+
isFetchingClassifications: false,
|
|
36
|
+
fetchError: { status: 401, response: "test error", url: "test url" },
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
it("returns initial state for unrecognized action", () => {
|
|
40
|
+
expect(reducer(undefined, {})).toStrictEqual(initState);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("handles GENRE_TREE_REQUEST", () => {
|
|
44
|
+
const action = { type: ActionCreator.GENRE_TREE_REQUEST, url: "test url" };
|
|
45
|
+
|
|
46
|
+
// start with empty state
|
|
47
|
+
let newState = Object.assign({}, initState, {
|
|
48
|
+
isFetchingGenreTree: true,
|
|
49
|
+
});
|
|
50
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
51
|
+
|
|
52
|
+
// start with error state
|
|
53
|
+
newState = Object.assign({}, errorState, {
|
|
54
|
+
isFetchingGenreTree: true,
|
|
55
|
+
fetchError: null,
|
|
56
|
+
});
|
|
57
|
+
expect(reducer(errorState, action)).toStrictEqual(newState);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("handles GENRE_TREE_FAILURE", () => {
|
|
61
|
+
const action = {
|
|
62
|
+
type: ActionCreator.GENRE_TREE_FAILURE,
|
|
63
|
+
error: "test error",
|
|
64
|
+
};
|
|
65
|
+
const oldState = Object.assign({}, initState, { isFetching: true });
|
|
66
|
+
const newState = Object.assign({}, oldState, {
|
|
67
|
+
fetchError: "test error",
|
|
68
|
+
isFetchingGenreTree: false,
|
|
69
|
+
});
|
|
70
|
+
expect(reducer(oldState, action)).toStrictEqual(newState);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("handles GENRE_TREE_LOAD", () => {
|
|
74
|
+
const action = { type: ActionCreator.GENRE_TREE_LOAD, data: genreData };
|
|
75
|
+
const newState = Object.assign({}, initState, {
|
|
76
|
+
genreTree: genreData,
|
|
77
|
+
isFetchingGenreTree: false,
|
|
78
|
+
});
|
|
79
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("handles EDIT_CLASSIFICATIONS_REQUEST", () => {
|
|
83
|
+
const action = {
|
|
84
|
+
type: ActionCreator.EDIT_CLASSIFICATIONS_REQUEST,
|
|
85
|
+
url: "test url",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// start with empty state
|
|
89
|
+
let newState = Object.assign({}, initState, {
|
|
90
|
+
isEditingClassifications: true,
|
|
91
|
+
});
|
|
92
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
93
|
+
|
|
94
|
+
// start with error state
|
|
95
|
+
newState = Object.assign({}, errorState, {
|
|
96
|
+
isEditingClassifications: true,
|
|
97
|
+
fetchError: null,
|
|
98
|
+
});
|
|
99
|
+
expect(reducer(errorState, action)).toStrictEqual(newState);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("handles EDIT_CLASSIFICATIONS_FAILURE", () => {
|
|
103
|
+
const action = {
|
|
104
|
+
type: ActionCreator.EDIT_CLASSIFICATIONS_FAILURE,
|
|
105
|
+
error: "test error",
|
|
106
|
+
};
|
|
107
|
+
const oldState = Object.assign({}, initState, {
|
|
108
|
+
isEditingClassifications: true,
|
|
109
|
+
});
|
|
110
|
+
const newState = Object.assign({}, oldState, {
|
|
111
|
+
fetchError: "test error",
|
|
112
|
+
isEditingClassifications: false,
|
|
113
|
+
});
|
|
114
|
+
expect(reducer(oldState, action)).toStrictEqual(newState);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("handles CLASSIFICATIONS_REQUEST", () => {
|
|
118
|
+
const action = {
|
|
119
|
+
type: ActionCreator.CLASSIFICATIONS_REQUEST,
|
|
120
|
+
url: "test url",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// start with empty state
|
|
124
|
+
let newState = Object.assign({}, initState, {
|
|
125
|
+
isFetchingClassifications: true,
|
|
126
|
+
});
|
|
127
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
128
|
+
|
|
129
|
+
// start with error state
|
|
130
|
+
newState = Object.assign({}, errorState, {
|
|
131
|
+
isFetchingClassifications: true,
|
|
132
|
+
fetchError: null,
|
|
133
|
+
});
|
|
134
|
+
expect(reducer(errorState, action)).toStrictEqual(newState);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("handles CLASSIFICATIONS_FAILURE", () => {
|
|
138
|
+
const action = {
|
|
139
|
+
type: ActionCreator.CLASSIFICATIONS_FAILURE,
|
|
140
|
+
error: "test error",
|
|
141
|
+
};
|
|
142
|
+
const oldState = Object.assign({}, initState, { isFetching: true });
|
|
143
|
+
const newState = Object.assign({}, oldState, {
|
|
144
|
+
fetchError: "test error",
|
|
145
|
+
isFetchingClassifications: false,
|
|
146
|
+
});
|
|
147
|
+
expect(reducer(oldState, action)).toStrictEqual(newState);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("handles CLASSIFICATIONS_LOAD", () => {
|
|
151
|
+
const action = {
|
|
152
|
+
type: ActionCreator.CLASSIFICATIONS_LOAD,
|
|
153
|
+
data: { classifications: classificationsData },
|
|
154
|
+
};
|
|
155
|
+
const newState = Object.assign({}, initState, {
|
|
156
|
+
classifications: classificationsData,
|
|
157
|
+
isFetchingClassifications: false,
|
|
158
|
+
});
|
|
159
|
+
expect(reducer(initState, action)).toStrictEqual(newState);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import collections from "../../../src/reducers/collections";
|
|
2
|
+
import ActionCreator from "../../../src/actions";
|
|
3
|
+
|
|
4
|
+
describe("collections reducer", () => {
|
|
5
|
+
const initState = {
|
|
6
|
+
data: null,
|
|
7
|
+
isFetching: false,
|
|
8
|
+
isEditing: false,
|
|
9
|
+
fetchError: null,
|
|
10
|
+
formError: null,
|
|
11
|
+
responseBody: null,
|
|
12
|
+
isLoaded: false,
|
|
13
|
+
successMessage: null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
it("returns initial state for unrecognized action", () => {
|
|
17
|
+
expect(collections(undefined, {})).toStrictEqual(initState);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("handles COLLECTIONS_REQUEST", () => {
|
|
21
|
+
const action = {
|
|
22
|
+
type: `${ActionCreator.COLLECTIONS}_REQUEST`,
|
|
23
|
+
url: "test url",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// start with empty state
|
|
27
|
+
const newState = Object.assign({}, initState, {
|
|
28
|
+
isFetching: true,
|
|
29
|
+
});
|
|
30
|
+
expect(collections(initState, action)).toStrictEqual(newState);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("handles EDIT_COLLECTION_REQUEST", () => {
|
|
34
|
+
const action = { type: `${ActionCreator.EDIT_COLLECTION}_REQUEST` };
|
|
35
|
+
const newState = Object.assign({}, initState, {
|
|
36
|
+
fetchError: null,
|
|
37
|
+
isFetching: false,
|
|
38
|
+
isEditing: true,
|
|
39
|
+
});
|
|
40
|
+
expect(collections(initState, action)).toStrictEqual(newState);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("handles GET_SELF_TESTS_LOAD", () => {
|
|
44
|
+
const emptySelfTestData = {
|
|
45
|
+
duration: null,
|
|
46
|
+
start: "",
|
|
47
|
+
end: "",
|
|
48
|
+
results: [],
|
|
49
|
+
};
|
|
50
|
+
const selfTestData = {
|
|
51
|
+
duration: 0.12,
|
|
52
|
+
start: "start",
|
|
53
|
+
end: "end",
|
|
54
|
+
results: [],
|
|
55
|
+
};
|
|
56
|
+
const action = {
|
|
57
|
+
type: `${ActionCreator.GET_SELF_TESTS}_LOAD`,
|
|
58
|
+
data: {
|
|
59
|
+
self_test_results: {
|
|
60
|
+
id: 1,
|
|
61
|
+
self_test_results: selfTestData,
|
|
62
|
+
protocol: "",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const oldState = {
|
|
67
|
+
url: "test url",
|
|
68
|
+
data: {
|
|
69
|
+
collections: [
|
|
70
|
+
{ id: 1, self_test_results: emptySelfTestData, protocol: "" },
|
|
71
|
+
{ id: 2, protocol: "" },
|
|
72
|
+
],
|
|
73
|
+
protocols: [],
|
|
74
|
+
},
|
|
75
|
+
isFetching: true,
|
|
76
|
+
fetchError: null,
|
|
77
|
+
editError: null,
|
|
78
|
+
isLoaded: true,
|
|
79
|
+
isEditing: false,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const newState = Object.assign({}, oldState, {
|
|
83
|
+
data: {
|
|
84
|
+
collections: [
|
|
85
|
+
{ id: 1, self_test_results: selfTestData, protocol: "" },
|
|
86
|
+
{ id: 2, protocol: "" },
|
|
87
|
+
],
|
|
88
|
+
protocols: [],
|
|
89
|
+
},
|
|
90
|
+
isFetching: false,
|
|
91
|
+
isLoaded: true,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(collections(oldState, action)).toStrictEqual(newState);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import complaints from "../../../src/reducers/complaints";
|
|
2
|
+
import ActionCreator from "../../../src/actions";
|
|
3
|
+
|
|
4
|
+
describe("complaints reducer", () => {
|
|
5
|
+
const initState = {
|
|
6
|
+
url: null,
|
|
7
|
+
data: null,
|
|
8
|
+
isFetching: false,
|
|
9
|
+
fetchError: null,
|
|
10
|
+
postError: null,
|
|
11
|
+
resolveError: null,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const errorState = {
|
|
15
|
+
url: "test url",
|
|
16
|
+
data: null,
|
|
17
|
+
isFetching: false,
|
|
18
|
+
fetchError: { status: 401, response: "test error", url: "test url" },
|
|
19
|
+
postError: null,
|
|
20
|
+
resolveError: null,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
it("returns initial state for unrecognized action", () => {
|
|
24
|
+
expect(complaints(undefined, {})).toStrictEqual(initState);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("handles COMPLAINTS_REQUEST", () => {
|
|
28
|
+
const action = { type: ActionCreator.COMPLAINTS_REQUEST, url: "test url" };
|
|
29
|
+
|
|
30
|
+
// start with empty state
|
|
31
|
+
let newState = Object.assign({}, initState, {
|
|
32
|
+
url: "test url",
|
|
33
|
+
isFetching: true,
|
|
34
|
+
});
|
|
35
|
+
expect(complaints(initState, action)).toStrictEqual(newState);
|
|
36
|
+
|
|
37
|
+
// start with error state
|
|
38
|
+
newState = Object.assign({}, errorState, {
|
|
39
|
+
isFetching: true,
|
|
40
|
+
fetchError: null,
|
|
41
|
+
});
|
|
42
|
+
expect(complaints(errorState, action)).toStrictEqual(newState);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("handles COMPLAINTS_FAILURE", () => {
|
|
46
|
+
const action = {
|
|
47
|
+
type: ActionCreator.COMPLAINTS_FAILURE,
|
|
48
|
+
error: "test error",
|
|
49
|
+
};
|
|
50
|
+
const oldState = {
|
|
51
|
+
url: "test url",
|
|
52
|
+
data: null,
|
|
53
|
+
isFetching: true,
|
|
54
|
+
fetchError: null,
|
|
55
|
+
postError: null,
|
|
56
|
+
resolveError: null,
|
|
57
|
+
};
|
|
58
|
+
const newState = Object.assign({}, oldState, {
|
|
59
|
+
fetchError: "test error",
|
|
60
|
+
isFetching: false,
|
|
61
|
+
});
|
|
62
|
+
expect(complaints(oldState, action)).toStrictEqual(newState);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("handles COMPLAINTS_LOAD", () => {
|
|
66
|
+
const action = {
|
|
67
|
+
type: ActionCreator.COMPLAINTS_LOAD,
|
|
68
|
+
data: { complaints: "test data" },
|
|
69
|
+
};
|
|
70
|
+
const oldState = {
|
|
71
|
+
url: "test url",
|
|
72
|
+
data: null,
|
|
73
|
+
isFetching: true,
|
|
74
|
+
fetchError: null,
|
|
75
|
+
postError: null,
|
|
76
|
+
resolveError: null,
|
|
77
|
+
};
|
|
78
|
+
const newState = Object.assign({}, oldState, {
|
|
79
|
+
data: "test data",
|
|
80
|
+
isFetching: false,
|
|
81
|
+
});
|
|
82
|
+
expect(complaints(oldState, action)).toStrictEqual(newState);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("handles POST_COMPLAINT_REQUEST", () => {
|
|
86
|
+
const action = {
|
|
87
|
+
type: ActionCreator.POST_COMPLAINT_REQUEST,
|
|
88
|
+
url: "test url",
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// start with empty state
|
|
92
|
+
let newState = Object.assign({}, initState, {
|
|
93
|
+
url: "test url",
|
|
94
|
+
isFetching: true,
|
|
95
|
+
});
|
|
96
|
+
expect(complaints(initState, action)).toStrictEqual(newState);
|
|
97
|
+
|
|
98
|
+
// start with error state
|
|
99
|
+
newState = Object.assign({}, errorState, {
|
|
100
|
+
isFetching: true,
|
|
101
|
+
fetchError: null,
|
|
102
|
+
});
|
|
103
|
+
expect(complaints(errorState, action)).toStrictEqual(newState);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("handles POST_COMPLAINT_FAILURE", () => {
|
|
107
|
+
const action = {
|
|
108
|
+
type: ActionCreator.POST_COMPLAINT_FAILURE,
|
|
109
|
+
error: "test error",
|
|
110
|
+
};
|
|
111
|
+
const oldState = {
|
|
112
|
+
url: "test url",
|
|
113
|
+
data: null,
|
|
114
|
+
isFetching: true,
|
|
115
|
+
fetchError: null,
|
|
116
|
+
postError: null,
|
|
117
|
+
resolveError: null,
|
|
118
|
+
};
|
|
119
|
+
const newState = Object.assign({}, oldState, {
|
|
120
|
+
postError: "test error",
|
|
121
|
+
isFetching: false,
|
|
122
|
+
});
|
|
123
|
+
expect(complaints(oldState, action)).toStrictEqual(newState);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("handles RESOLVE_COMPLAINTS_REQUEST", () => {
|
|
127
|
+
const action = {
|
|
128
|
+
type: ActionCreator.RESOLVE_COMPLAINTS_REQUEST,
|
|
129
|
+
url: "test url",
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// start with empty state
|
|
133
|
+
let newState = Object.assign({}, initState, {
|
|
134
|
+
url: "test url",
|
|
135
|
+
isFetching: true,
|
|
136
|
+
});
|
|
137
|
+
expect(complaints(initState, action)).toStrictEqual(newState);
|
|
138
|
+
|
|
139
|
+
// start with error state
|
|
140
|
+
newState = Object.assign({}, errorState, {
|
|
141
|
+
isFetching: true,
|
|
142
|
+
fetchError: null,
|
|
143
|
+
});
|
|
144
|
+
expect(complaints(errorState, action)).toStrictEqual(newState);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("handles RESOLVE_COMPLAINTS_FAILURE", () => {
|
|
148
|
+
const action = {
|
|
149
|
+
type: ActionCreator.RESOLVE_COMPLAINTS_FAILURE,
|
|
150
|
+
error: "test error",
|
|
151
|
+
};
|
|
152
|
+
const oldState = {
|
|
153
|
+
url: "test url",
|
|
154
|
+
data: null,
|
|
155
|
+
isFetching: true,
|
|
156
|
+
fetchError: null,
|
|
157
|
+
postError: null,
|
|
158
|
+
resolveError: null,
|
|
159
|
+
};
|
|
160
|
+
const newState = Object.assign({}, oldState, {
|
|
161
|
+
resolveError: "test error",
|
|
162
|
+
isFetching: false,
|
|
163
|
+
});
|
|
164
|
+
expect(complaints(oldState, action)).toStrictEqual(newState);
|
|
165
|
+
});
|
|
166
|
+
});
|