@thepalaceproject/circulation-admin 1.43.0-post.3 → 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.
@@ -0,0 +1,120 @@
1
+ import customListDetails from "../../../src/reducers/customListDetails";
2
+ import ActionCreator from "../../../src/actions";
3
+
4
+ describe("customListDetails reducer", () => {
5
+ const initState = {
6
+ data: null,
7
+ isFetching: false,
8
+ isEditing: false,
9
+ fetchError: null,
10
+ formError: null,
11
+ responseBody: null,
12
+ successMessage: null,
13
+ isLoaded: false,
14
+ };
15
+
16
+ it("returns initial state for unrecognized action", () => {
17
+ expect(customListDetails(undefined, {})).toStrictEqual(initState);
18
+ });
19
+
20
+ it("handles CUSTOM_LIST_DETAILS_REQUEST", () => {
21
+ const action = {
22
+ type: `${ActionCreator.CUSTOM_LIST_DETAILS}_REQUEST`,
23
+ url: "test url",
24
+ };
25
+
26
+ // start with empty state
27
+ const newState = Object.assign({}, initState, {
28
+ isFetching: true,
29
+ });
30
+ expect(customListDetails(initState, action)).toStrictEqual(newState);
31
+ });
32
+
33
+ it("handles CUSTOM_LIST_DETAILS_MORE_REQUEST", () => {
34
+ const action = {
35
+ type: `${ActionCreator.CUSTOM_LIST_DETAILS_MORE}_REQUEST`,
36
+ url: "test url",
37
+ };
38
+ const oldState = {
39
+ url: "test url",
40
+ data: null,
41
+ isFetching: false,
42
+ isFetchingMoreEntries: false,
43
+ fetchError: null,
44
+ editError: null,
45
+ isLoaded: true,
46
+ isEditing: false,
47
+ };
48
+
49
+ const newState = Object.assign({}, oldState, {
50
+ isFetchingMoreEntries: true,
51
+ isLoaded: false,
52
+ });
53
+
54
+ expect(customListDetails(oldState, action)).toStrictEqual(newState);
55
+ });
56
+
57
+ it("handles CUSTOM_LIST_DETAILS_MORE_LOAD", () => {
58
+ const action = {
59
+ type: `${ActionCreator.CUSTOM_LIST_DETAILS_MORE}_LOAD`,
60
+ data: {
61
+ id: "1",
62
+ url: "url",
63
+ books: [
64
+ { id: "4", title: "4" },
65
+ { id: "5", title: "5" },
66
+ { id: "6", title: "6" },
67
+ ],
68
+ nextPageUrl: "nextpage?after=100",
69
+ navigationLinks: [],
70
+ lanes: [],
71
+ },
72
+ };
73
+ const oldState = {
74
+ url: "test url",
75
+ data: {
76
+ id: "1",
77
+ url: "url",
78
+ title: "custom list",
79
+ books: [
80
+ { id: "1", title: "1" },
81
+ { id: "2", title: "2" },
82
+ { id: "3", title: "3" },
83
+ ],
84
+ nextPageUrl: "nextpage?after=50",
85
+ navigationLinks: [],
86
+ lanes: [],
87
+ },
88
+ isFetching: false,
89
+ isFetchingMoreEntries: false,
90
+ fetchError: null,
91
+ editError: null,
92
+ isLoaded: true,
93
+ isEditing: false,
94
+ };
95
+
96
+ const newState = Object.assign({}, oldState, {
97
+ data: {
98
+ id: "1",
99
+ url: "url",
100
+ title: "custom list",
101
+ books: [
102
+ { id: "1", title: "1" },
103
+ { id: "2", title: "2" },
104
+ { id: "3", title: "3" },
105
+ { id: "4", title: "4" },
106
+ { id: "5", title: "5" },
107
+ { id: "6", title: "6" },
108
+ ],
109
+ nextPageUrl: "nextpage?after=100",
110
+ navigationLinks: [],
111
+ lanes: [],
112
+ },
113
+ isFetching: false,
114
+ isFetchingMoreEntries: false,
115
+ isLoaded: true,
116
+ });
117
+
118
+ expect(customListDetails(oldState, action)).toStrictEqual(newState);
119
+ });
120
+ });