redux-paginator-immutable 17.0.18 → 17.0.19
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/lib/Info.d.ts +9 -0
- package/lib/Info.js +19 -0
- package/lib/Info.js.map +1 -0
- package/lib/LoadDataItem.d.ts +23 -0
- package/lib/LoadDataItem.js +59 -0
- package/lib/LoadDataItem.js.map +1 -0
- package/lib/LoadPaginator.d.ts +41 -0
- package/lib/LoadPaginator.js +109 -0
- package/lib/LoadPaginator.js.map +1 -0
- package/lib/LoadingButton.d.ts +11 -0
- package/lib/LoadingButton.js +22 -0
- package/lib/LoadingButton.js.map +1 -0
- package/lib/actionTypes.d.ts +9 -0
- package/lib/actionTypes.js +13 -0
- package/lib/actionTypes.js.map +1 -0
- package/lib/actions.d.ts +42 -0
- package/lib/actions.js +82 -0
- package/lib/actions.js.map +1 -0
- package/lib/agent.d.ts +8 -0
- package/lib/agent.js +37 -0
- package/lib/agent.js.map +1 -0
- package/lib/createDataReducer.d.ts +36 -0
- package/lib/createDataReducer.js +79 -0
- package/lib/createDataReducer.js.map +1 -0
- package/lib/createItemReducer.d.ts +11 -0
- package/lib/createItemReducer.js +18 -0
- package/lib/createItemReducer.js.map +1 -0
- package/lib/createPaginator.d.ts +14 -0
- package/lib/createPaginator.js +84 -0
- package/lib/createPaginator.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +30 -0
- package/lib/index.js.map +1 -0
- package/lib/paginatorMiddleware.d.ts +5 -0
- package/lib/paginatorMiddleware.js +68 -0
- package/lib/paginatorMiddleware.js.map +1 -0
- package/lib/reducerItemData.d.ts +18 -0
- package/lib/reducerItemData.js +56 -0
- package/lib/reducerItemData.js.map +1 -0
- package/lib/reducerOperations.d.ts +3 -0
- package/lib/reducerOperations.js +69 -0
- package/lib/reducerOperations.js.map +1 -0
- package/lib/reducers.d.ts +4 -0
- package/lib/reducers.js +75 -0
- package/lib/reducers.js.map +1 -0
- package/lib/selectors.d.ts +58 -0
- package/lib/selectors.js +79 -0
- package/lib/selectors.js.map +1 -0
- package/lib/types/actions.d.ts +85 -0
- package/lib/types/actions.js +3 -0
- package/lib/types/actions.js.map +1 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/index.js +16 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/state.d.ts +6 -0
- package/lib/types/state.js +3 -0
- package/lib/types/state.js.map +1 -0
- package/lib/util.d.ts +9 -0
- package/lib/util.js +49 -0
- package/lib/util.js.map +1 -0
- package/lib/words.d.ts +9 -0
- package/lib/words.js +12 -0
- package/lib/words.js.map +1 -0
- package/package.json +24 -17
- package/lib/__tests__/actions.spec.js +0 -117
- package/lib/__tests__/agent.spec.js +0 -32
- package/lib/__tests__/createPaginator.spec.js +0 -39
- package/lib/__tests__/reducers.spec.js +0 -125
- package/lib/__tests__/selectors.spec.js +0 -160
- package/lib/__tests__/setup.js +0 -3
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _expect = require("expect");
|
|
4
|
-
|
|
5
|
-
var _expect2 = _interopRequireDefault(_expect);
|
|
6
|
-
|
|
7
|
-
var _actions = require("../actions");
|
|
8
|
-
|
|
9
|
-
var _actions2 = _interopRequireDefault(_actions);
|
|
10
|
-
|
|
11
|
-
var _createPaginator = require("../createPaginator");
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
var requestPage = _actions2.default.requestPage; /* eslint-disable max-len, no-undefined, no-magic-numbers */
|
|
16
|
-
|
|
17
|
-
describe("createPaginator", function () {
|
|
18
|
-
|
|
19
|
-
it("should create correct request action creator", function () {
|
|
20
|
-
var paginator = (0, _createPaginator.createPaginator)("some/api/endpoint", {
|
|
21
|
-
pageArgName: "p",
|
|
22
|
-
idKey: "id_field",
|
|
23
|
-
resultsKey: "results",
|
|
24
|
-
totalKey: "count"
|
|
25
|
-
}),
|
|
26
|
-
action = paginator.requestPage(42, "foo=bar");
|
|
27
|
-
|
|
28
|
-
(0, _expect2.default)(action).toEqual(requestPage({
|
|
29
|
-
endpoint: "some/api/endpoint",
|
|
30
|
-
endpointCb: null,
|
|
31
|
-
resultsKey: "results",
|
|
32
|
-
totalKey: "count",
|
|
33
|
-
pageArgName: "p",
|
|
34
|
-
idKey: "id_field",
|
|
35
|
-
page: 42,
|
|
36
|
-
token: "foo=bar"
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _immutable = require("immutable");
|
|
4
|
-
|
|
5
|
-
var Immutable = _interopRequireWildcard(_immutable);
|
|
6
|
-
|
|
7
|
-
var _chai = require("chai");
|
|
8
|
-
|
|
9
|
-
var _chai2 = _interopRequireDefault(_chai);
|
|
10
|
-
|
|
11
|
-
var _chaiImmutable = require("chai-immutable");
|
|
12
|
-
|
|
13
|
-
var _chaiImmutable2 = _interopRequireDefault(_chaiImmutable);
|
|
14
|
-
|
|
15
|
-
var _actions = require("../actions");
|
|
16
|
-
|
|
17
|
-
var _actions2 = _interopRequireDefault(_actions);
|
|
18
|
-
|
|
19
|
-
var _reducers = require("../reducers");
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
24
|
-
|
|
25
|
-
_chai2.default.use(_chaiImmutable2.default); /* eslint-disable max-len, no-undefined, max-lines-per-function */
|
|
26
|
-
|
|
27
|
-
var requestPage = _actions2.default.requestPage,
|
|
28
|
-
receivePage = _actions2.default.receivePage;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var requestPageAction = requestPage({
|
|
32
|
-
endpoint: "some/api/endpoint",
|
|
33
|
-
resultsKey: "results",
|
|
34
|
-
totalKey: "total",
|
|
35
|
-
pageArgName: "p",
|
|
36
|
-
idKey: "id",
|
|
37
|
-
page: 2,
|
|
38
|
-
token: "foo=bar"
|
|
39
|
-
}),
|
|
40
|
-
receivePageAction = receivePage({
|
|
41
|
-
endpoint: "some/api/endpoint/",
|
|
42
|
-
pageArgName: "p",
|
|
43
|
-
idKey: "id",
|
|
44
|
-
page: 2,
|
|
45
|
-
token: "foo=bar",
|
|
46
|
-
items: [{
|
|
47
|
-
id: "baz",
|
|
48
|
-
fooField: "bazValue"
|
|
49
|
-
}, {
|
|
50
|
-
id: "bar",
|
|
51
|
-
fooField: "barValue"
|
|
52
|
-
}],
|
|
53
|
-
total: 2
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("pages reducer", function () {
|
|
57
|
-
|
|
58
|
-
it("should return the state by default", function () {
|
|
59
|
-
var state = (0, _reducers.pages)(Immutable.Map({
|
|
60
|
-
some: "state"
|
|
61
|
-
}), { type: "some action" });
|
|
62
|
-
|
|
63
|
-
(0, _chai.expect)(state).to.equal(Immutable.Map({
|
|
64
|
-
some: "state"
|
|
65
|
-
}));
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("should initialize the pages map with a new page entry when requesting new page", function () {
|
|
69
|
-
var state = (0, _reducers.pages)(undefined, requestPageAction);
|
|
70
|
-
|
|
71
|
-
(0, _chai.expect)(state).to.equal(Immutable.Map({
|
|
72
|
-
"foo=bar": Immutable.Map({
|
|
73
|
-
page: 2,
|
|
74
|
-
token: "foo=bar",
|
|
75
|
-
ids: Immutable.List(),
|
|
76
|
-
fetching: true,
|
|
77
|
-
error: false,
|
|
78
|
-
view: 1,
|
|
79
|
-
fetched: false
|
|
80
|
-
})
|
|
81
|
-
}));
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("should populate the pages map at the page url key with the item ids", function () {
|
|
85
|
-
var state = (0, _reducers.pages)(Immutable.Map({
|
|
86
|
-
"foo=bar": Immutable.Map({
|
|
87
|
-
page: 2,
|
|
88
|
-
token: "foo=bar",
|
|
89
|
-
ids: Immutable.List(),
|
|
90
|
-
fetching: true,
|
|
91
|
-
fetched: false
|
|
92
|
-
})
|
|
93
|
-
}), receivePageAction);
|
|
94
|
-
|
|
95
|
-
(0, _chai.expect)(state).to.equal(Immutable.Map({
|
|
96
|
-
"foo=bar": Immutable.Map({
|
|
97
|
-
page: 2,
|
|
98
|
-
token: "foo=bar",
|
|
99
|
-
ids: Immutable.List(["baz", "bar"]),
|
|
100
|
-
fetching: false,
|
|
101
|
-
fetched: true,
|
|
102
|
-
error: false,
|
|
103
|
-
total: 2
|
|
104
|
-
})
|
|
105
|
-
}));
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe("items reducer", function () {
|
|
110
|
-
|
|
111
|
-
it("should populate the items map with item received", function () {
|
|
112
|
-
var state = (0, _reducers.items)(undefined, receivePageAction);
|
|
113
|
-
|
|
114
|
-
(0, _chai.expect)(state).to.equal(Immutable.Map({
|
|
115
|
-
"baz": Immutable.Map({
|
|
116
|
-
id: "baz",
|
|
117
|
-
fooField: "bazValue"
|
|
118
|
-
}),
|
|
119
|
-
"bar": Immutable.Map({
|
|
120
|
-
id: "bar",
|
|
121
|
-
fooField: "barValue"
|
|
122
|
-
})
|
|
123
|
-
}));
|
|
124
|
-
});
|
|
125
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _chai = require("chai");
|
|
4
|
-
|
|
5
|
-
var _chai2 = _interopRequireDefault(_chai);
|
|
6
|
-
|
|
7
|
-
var _chaiImmutable = require("chai-immutable");
|
|
8
|
-
|
|
9
|
-
var _chaiImmutable2 = _interopRequireDefault(_chaiImmutable);
|
|
10
|
-
|
|
11
|
-
var _immutable = require("immutable");
|
|
12
|
-
|
|
13
|
-
var Immutable = _interopRequireWildcard(_immutable);
|
|
14
|
-
|
|
15
|
-
var _selectors = require("../selectors");
|
|
16
|
-
|
|
17
|
-
var _selectors2 = _interopRequireDefault(_selectors);
|
|
18
|
-
|
|
19
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
/* eslint-disable max-len, no-undefined, max-lines-per-function, no-magic-numbers */
|
|
24
|
-
|
|
25
|
-
_chai2.default.use(_chaiImmutable2.default);
|
|
26
|
-
|
|
27
|
-
var getCurrentTotalResultsCount = _selectors2.default.getCurrentTotalResultsCount,
|
|
28
|
-
getAllResults = _selectors2.default.getAllResults,
|
|
29
|
-
getResultsUpToPage = _selectors2.default.getResultsUpToPage,
|
|
30
|
-
isPageFetched = _selectors2.default.isPageFetched,
|
|
31
|
-
isPageFetching = _selectors2.default.isPageFetching,
|
|
32
|
-
getCurrentView = _selectors2.default.getCurrentView,
|
|
33
|
-
paginator = Immutable.Map({
|
|
34
|
-
"foo=bar": Immutable.Map({
|
|
35
|
-
page: 3,
|
|
36
|
-
token: "foo=bar",
|
|
37
|
-
ids: Immutable.List([1, 2, 3, 7, 8, 9]),
|
|
38
|
-
total: 42,
|
|
39
|
-
view: 2,
|
|
40
|
-
fetching: false,
|
|
41
|
-
fetched: true
|
|
42
|
-
}),
|
|
43
|
-
"foo=baz": Immutable.Map({
|
|
44
|
-
page: 1,
|
|
45
|
-
token: "foo=baz",
|
|
46
|
-
ids: Immutable.List([1, 4, 6]),
|
|
47
|
-
fetching: false,
|
|
48
|
-
fetched: true,
|
|
49
|
-
total: 17,
|
|
50
|
-
view: 1
|
|
51
|
-
})
|
|
52
|
-
}),
|
|
53
|
-
items = Immutable.Map({
|
|
54
|
-
"1": Immutable.Map({
|
|
55
|
-
data: "foo1",
|
|
56
|
-
id: 1
|
|
57
|
-
}),
|
|
58
|
-
"2": Immutable.Map({
|
|
59
|
-
data: "foo2",
|
|
60
|
-
id: 2
|
|
61
|
-
}),
|
|
62
|
-
"3": Immutable.Map({
|
|
63
|
-
data: "foo3",
|
|
64
|
-
id: 3
|
|
65
|
-
}),
|
|
66
|
-
"4": Immutable.Map({
|
|
67
|
-
data: "foo4",
|
|
68
|
-
id: 4
|
|
69
|
-
}),
|
|
70
|
-
"5": Immutable.Map({
|
|
71
|
-
data: "foo5",
|
|
72
|
-
id: 5
|
|
73
|
-
}),
|
|
74
|
-
"6": Immutable.Map({
|
|
75
|
-
data: "foo6",
|
|
76
|
-
id: 6
|
|
77
|
-
}),
|
|
78
|
-
"7": Immutable.Map({
|
|
79
|
-
data: "foo7",
|
|
80
|
-
id: 7
|
|
81
|
-
}),
|
|
82
|
-
"8": Immutable.Map({
|
|
83
|
-
data: "foo8",
|
|
84
|
-
id: 8
|
|
85
|
-
}),
|
|
86
|
-
"9": Immutable.Map({
|
|
87
|
-
data: "foo9",
|
|
88
|
-
id: 9
|
|
89
|
-
})
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
describe("selectors", function () {
|
|
94
|
-
|
|
95
|
-
it("getAllResults should select all the items ids for pages with same params than the current page", function () {
|
|
96
|
-
(0, _chai.expect)(getAllResults(paginator, "foo=bar", items)).to.equal(Immutable.List([Immutable.Map({
|
|
97
|
-
data: "foo1",
|
|
98
|
-
id: 1
|
|
99
|
-
}), Immutable.Map({
|
|
100
|
-
data: "foo2",
|
|
101
|
-
id: 2
|
|
102
|
-
}), Immutable.Map({
|
|
103
|
-
data: "foo3",
|
|
104
|
-
id: 3
|
|
105
|
-
}), Immutable.Map({
|
|
106
|
-
data: "foo7",
|
|
107
|
-
id: 7
|
|
108
|
-
}), Immutable.Map({
|
|
109
|
-
data: "foo8",
|
|
110
|
-
id: 8
|
|
111
|
-
}), Immutable.Map({
|
|
112
|
-
data: "foo9",
|
|
113
|
-
id: 9
|
|
114
|
-
})]));
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it("getResultsUpToPage should select all the items ids for pages with same params than the current page", function () {
|
|
118
|
-
(0, _chai.expect)(getResultsUpToPage(paginator, "foo=bar", items, 2, 2)).to.equal(Immutable.List([Immutable.Map({
|
|
119
|
-
data: "foo1",
|
|
120
|
-
id: 1
|
|
121
|
-
}), Immutable.Map({
|
|
122
|
-
data: "foo2",
|
|
123
|
-
id: 2
|
|
124
|
-
}), Immutable.Map({
|
|
125
|
-
data: "foo3",
|
|
126
|
-
id: 3
|
|
127
|
-
}), Immutable.Map({
|
|
128
|
-
data: "foo7",
|
|
129
|
-
id: 7
|
|
130
|
-
})]));
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("getCurrentTotalResultsCount should return the total count for the current params of the provided name", function () {
|
|
134
|
-
(0, _chai.expect)(getCurrentTotalResultsCount(paginator, "foo=bar")).to.equal(42);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("getCurrentTotalResultsCount should return 0 if current page url is undefined for the provided name", function () {
|
|
138
|
-
(0, _chai.expect)(getCurrentTotalResultsCount(paginator, "name3")).to.equal(0);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("isPageFetching should return whether the current page is fetching or not for the provided name", function () {
|
|
142
|
-
(0, _chai.expect)(isPageFetching(paginator, "foo=bar", 1)).to.equal(false);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("isPageFetched should return whether the current page is fetched or not for the provided name", function () {
|
|
146
|
-
(0, _chai.expect)(isPageFetched(paginator, "foo=bar", 1)).to.equal(true);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("isPageFetched should return whether the current page is fetched or not for the provided name", function () {
|
|
150
|
-
(0, _chai.expect)(isPageFetched(paginator, "foo=bar", 4)).to.equal(false);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it("getCurrentView should return 1 if there is no view point", function () {
|
|
154
|
-
(0, _chai.expect)(getCurrentView(paginator, "foo=bat")).to.equal(1);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("getCurrentView should return the value if it exists", function () {
|
|
158
|
-
(0, _chai.expect)(getCurrentView(paginator, "foo=bar")).to.equal(2);
|
|
159
|
-
});
|
|
160
|
-
});
|
package/lib/__tests__/setup.js
DELETED