@shopgate/pwa-common-commerce 7.31.5 → 7.31.6

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.
@@ -1,40 +0,0 @@
1
- import errorReviews from "./errorReviews";
2
- import receiveReviews from "./receiveReviews";
3
- import requestReviews from "./requestReviews";
4
- import { ERROR_REVIEWS, RECEIVE_REVIEWS, REQUEST_REVIEWS } from "../constants/index";
5
- const hash = 'foo';
6
- const productId = '1';
7
- describe('Reviews action-creators', () => {
8
- describe('errorReviews', () => {
9
- it('should return correct action', () => {
10
- const action = errorReviews(hash);
11
- expect(action).toEqual({
12
- type: ERROR_REVIEWS,
13
- hash
14
- });
15
- });
16
- });
17
- describe('receiveReviews', () => {
18
- it('should return correct action', () => {
19
- const reviews = [];
20
- const totalReviewCount = 20;
21
- const action = receiveReviews(hash, productId, reviews, totalReviewCount);
22
- expect(action).toEqual({
23
- type: RECEIVE_REVIEWS,
24
- hash,
25
- productId,
26
- reviews,
27
- totalReviewCount
28
- });
29
- });
30
- });
31
- describe('requestReviews', () => {
32
- it('should return correct action', () => {
33
- const action = requestReviews(hash);
34
- expect(action).toEqual({
35
- type: REQUEST_REVIEWS,
36
- hash
37
- });
38
- });
39
- });
40
- });
@@ -1,255 +0,0 @@
1
- import { logger } from '@shopgate/pwa-core/helpers';
2
- import { mockedPipelineRequestFactory } from '@shopgate/pwa-core/classes/PipelineRequest/mock';
3
- import { EUNKNOWN, EACCESS } from '@shopgate/pwa-core/constants/Pipeline';
4
- import fetchReviews from "./fetchReviews";
5
- import fetchProductReviews from "./fetchProductReviews";
6
- import fetchUserReview from "./fetchUserReview";
7
- import submitReview from "./submitReview";
8
- import { finalState } from "../selectors/mock";
9
- import * as pipelines from "../constants/Pipelines";
10
- let mockedResolver;
11
- jest.mock('@shopgate/pwa-core/classes/PipelineRequest', () => mockedPipelineRequestFactory((mockInstance, resolve, reject) => {
12
- mockedResolver(mockInstance, resolve, reject);
13
- }));
14
- jest.mock('@shopgate/pwa-core/helpers', () => ({
15
- logger: {
16
- error: jest.fn()
17
- }
18
- }));
19
- describe.skip('Reviews actions', () => {
20
- describe('fetchReviews', () => {
21
- beforeEach(() => {
22
- jest.clearAllMocks();
23
- });
24
- it('should resolve and call appropriate actions', async done => {
25
- mockedResolver = (mockInstance, resolve) => {
26
- resolve({
27
- reviews: [],
28
- mockInstance
29
- });
30
- };
31
- const mockedDispatch = jest.fn();
32
- try {
33
- const result = await fetchReviews('foo', 2, 1)(mockedDispatch);
34
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS);
35
- expect(result.mockInstance.input).toEqual({
36
- productId: 'foo',
37
- limit: 2,
38
- offset: 1,
39
- sort: 'dateDesc'
40
- });
41
- expect(logger.error).toHaveBeenCalledTimes(0);
42
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
43
- done();
44
- } catch (err) {
45
- done(err);
46
- }
47
- });
48
- it('should fail and call appropriate actions', async done => {
49
- mockedResolver = (mockInstance, resolve, reject) => {
50
- reject({
51
- mockInstance
52
- });
53
- };
54
- const mockedDispatch = jest.fn();
55
- let result;
56
- try {
57
- result = await fetchReviews('foo', 2, 1)(mockedDispatch);
58
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS);
59
- expect(result.mockInstance.input).toEqual({
60
- productId: 'foo',
61
- limit: 2,
62
- offset: 1,
63
- sort: 'dateDesc'
64
- });
65
- expect(logger.error).toHaveBeenCalledTimes(1);
66
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
67
- done();
68
- } catch (err) {
69
- done(err);
70
- }
71
- });
72
- });
73
- describe('fetchProductReviews', () => {
74
- /**
75
- * Assertion helper function
76
- * @param {string} variant ('then' or 'catch')
77
- * @param {Function} done Async test case done callback function.
78
- * @param {Object} state React state.
79
- */
80
- const testFetchProductReviews = (variant, done, state) => {
81
- const mockedDispatch = jest.fn();
82
- const promise = fetchProductReviews('foo', 10, 'invalidSort')(mockedDispatch, () => state);
83
- setTimeout(() => {
84
- promise[variant](result => {
85
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS);
86
- expect(result.mockInstance.input).toEqual({
87
- productId: 'foo',
88
- limit: 10,
89
- sort: 'invalidSort'
90
- });
91
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
92
- done();
93
- });
94
- }, 0);
95
- };
96
- it('should resolve and call appropriate actions', async done => {
97
- mockedResolver = (mockInstance, resolve) => {
98
- resolve({
99
- reviews: [],
100
- mockInstance
101
- });
102
- };
103
- const mockedDispatch = jest.fn();
104
- try {
105
- const result = await fetchProductReviews('foo', 10, 'invalidSort')(mockedDispatch, () => finalState);
106
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS);
107
- expect(result.mockInstance.input).toEqual({
108
- productId: 'foo',
109
- limit: 10,
110
- sort: 'invalidSort'
111
- });
112
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
113
- done();
114
- } catch (err) {
115
- done(err);
116
- }
117
- });
118
- it('should reject and call appropriate actions', async done => {
119
- mockedResolver = (mockInstance, resolve, reject) => {
120
- reject({
121
- mockInstance
122
- });
123
- };
124
- const mockedDispatch = jest.fn();
125
- let result;
126
- try {
127
- result = await fetchProductReviews('foo', 10, 'invalidSort')(mockedDispatch, () => finalState);
128
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_CATALOG_GET_PRODUCT_REVIEWS);
129
- expect(result.mockInstance.input).toEqual({
130
- productId: 'foo',
131
- limit: 10,
132
- sort: 'invalidSort'
133
- });
134
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
135
- done();
136
- } catch (err) {
137
- done(err);
138
- }
139
- testFetchProductReviews('catch', done, finalState);
140
- });
141
- });
142
- describe('fetchUserReview', () => {
143
- /**
144
- * Assertion helper function
145
- * @param {string} variant ('then' or 'catch')
146
- * @param {Function} done Async test case done callback function.
147
- * @param {Object} state React state.
148
- */
149
- const testFetchUserReview = (variant, done, state) => {
150
- const mockedDispatch = jest.fn();
151
- const promise = fetchUserReview('foo')(mockedDispatch, () => state);
152
- setTimeout(() => {
153
- promise[variant](result => {
154
- expect(result.mockInstance.name).toBe(pipelines.SHOPGATE_USER_GET_REVIEW);
155
- expect(result.mockInstance.errorBlacklist).toEqual([EUNKNOWN, EACCESS]);
156
- expect(result.mockInstance.input).toEqual({
157
- productId: 'foo'
158
- });
159
- expect(mockedDispatch).toHaveBeenCalledTimes(2);
160
- done();
161
- });
162
- }, 0);
163
- };
164
- it('should resolve and call appropriate actions', done => {
165
- mockedResolver = (mockInstance, resolve) => {
166
- resolve({
167
- reviews: [],
168
- mockInstance
169
- });
170
- };
171
- testFetchUserReview('then', done, finalState);
172
- });
173
- it('should reject and call appropriate actions', done => {
174
- mockedResolver = (mockInstance, resolve, reject) => {
175
- reject({
176
- mockInstance
177
- });
178
- };
179
- testFetchUserReview('catch', done, finalState);
180
- });
181
- });
182
- describe('submitReview', () => {
183
- const testReviewInput = {
184
- productId: 'foo',
185
- rate: 10,
186
- title: ' Title ',
187
- author: ' Author ',
188
- review: 'RRRR '
189
- };
190
- const testReviewSanitized = {
191
- productId: 'foo',
192
- rate: 10,
193
- title: 'Title',
194
- author: 'Author',
195
- review: 'RRRR'
196
- };
197
- /**
198
- * Assertion helper function
199
- * @param {string} variant ('then' or 'catch')
200
- * @param {Object} review Review.
201
- * @param {boolean} update Update.
202
- * @param {Object} state React state.
203
- * @param {Function} done Async test case done callback function.
204
- */
205
- const testSubmitReview = (variant, review, update, state, done) => {
206
- const expectedDispatches = variant === 'then' ? 3 : 2;
207
- const mockedDispatch = jest.fn();
208
- const promise = submitReview(review, update)(mockedDispatch, () => state);
209
- setTimeout(() => {
210
- promise[variant](result => {
211
- expect(result.mockInstance.name).toBe(update ? pipelines.SHOPGATE_CATALOG_UPDATE_PRODUCT_REVIEW : pipelines.SHOPGATE_CATALOG_ADD_PRODUCT_REVIEW);
212
- expect(result.mockInstance.input).toEqual(testReviewSanitized);
213
- expect(mockedDispatch).toHaveBeenCalledTimes(expectedDispatches);
214
- done();
215
- });
216
- }, 0);
217
- };
218
- it('should resolve and call appropriate actions on update', done => {
219
- mockedResolver = (mockInstance, resolve) => {
220
- resolve({
221
- reviews: [],
222
- mockInstance
223
- });
224
- };
225
- testSubmitReview('then', testReviewInput, true, finalState, done);
226
- });
227
- it('should resolve and call appropriate actions on add', done => {
228
- mockedResolver = (mockInstance, resolve) => {
229
- resolve({
230
- reviews: [],
231
- mockInstance
232
- });
233
- };
234
- testSubmitReview('then', testReviewInput, false, finalState, done);
235
- });
236
- it('should reject and call appropriate actions on add', done => {
237
- mockedResolver = (mockInstance, resolve, reject) => {
238
- reject({
239
- reviews: [],
240
- mockInstance
241
- });
242
- };
243
- testSubmitReview('catch', testReviewInput, false, finalState, done);
244
- });
245
- it('should reject and call appropriate actions on update', done => {
246
- mockedResolver = (mockInstance, resolve, reject) => {
247
- reject({
248
- reviews: [],
249
- mockInstance
250
- });
251
- };
252
- testSubmitReview('catch', testReviewInput, true, finalState, done);
253
- });
254
- });
255
- });
@@ -1,214 +0,0 @@
1
- import { RECEIVE_REVIEWS, REQUEST_REVIEWS, ERROR_REVIEWS, REQUEST_PRODUCT_REVIEWS, RECEIVE_PRODUCT_REVIEWS, ERROR_PRODUCT_REVIEWS, REQUEST_USER_REVIEW, RECEIVE_USER_REVIEW, ERROR_USER_REVIEW, REQUEST_SUBMIT_REVIEW, RECEIVE_SUBMIT_REVIEW, ERROR_SUBMIT_REVIEW, RESET_SUBMIT_REVIEW } from "../constants";
2
- import { mockedReviews, moreMockedReviews, totalReviewCount } from "./mock";
3
- import reducers from "./index";
4
- describe('Reviews reducers', () => {
5
- describe('ReviewsByHash', () => {
6
- const hash = 'foo';
7
- let state = {};
8
-
9
- /**
10
- * Helper function for comparing changed state against expected shape.
11
- * @param {Object} receivedState State.
12
- * @param {number} expectedReviewsLength How many reviews should be stored.
13
- */
14
- const analyzeReceivedState = (receivedState, expectedReviewsLength = totalReviewCount) => {
15
- expect(receivedState.reviewsByHash[hash].totalReviewCount).toBe(totalReviewCount);
16
- expect(receivedState.reviewsByHash[hash].reviews).toBeInstanceOf(Array);
17
- expect(receivedState.reviewsByHash[hash].reviews).toBeInstanceOf(Array);
18
- expect(receivedState.reviewsByHash[hash].reviews).toHaveLength(expectedReviewsLength);
19
- };
20
- describe(REQUEST_REVIEWS, () => {
21
- it('should manipulate state when REQUEST_REVIEWS', () => {
22
- state = reducers(state, {
23
- type: REQUEST_REVIEWS,
24
- hash
25
- });
26
- expect(state.reviewsByHash[hash]).toEqual({
27
- expires: 0,
28
- isFetching: true
29
- });
30
- });
31
- });
32
- describe(RECEIVE_REVIEWS, () => {
33
- it('should manipulate state when receive reviews', () => {
34
- state = reducers(state, {
35
- type: RECEIVE_REVIEWS,
36
- hash,
37
- reviews: mockedReviews,
38
- totalReviewCount
39
- });
40
- analyzeReceivedState(state, mockedReviews.length);
41
- expect(state.reviewsByHash[hash].expires).toBeGreaterThan(Date.now());
42
- });
43
- it('should append more reviews when received more', () => {
44
- state = reducers(state, {
45
- type: RECEIVE_REVIEWS,
46
- hash,
47
- reviews: moreMockedReviews,
48
- totalReviewCount
49
- });
50
- analyzeReceivedState(state);
51
- expect(state.reviewsByHash[hash].expires).toBeGreaterThan(Date.now());
52
- });
53
- });
54
- describe(ERROR_REVIEWS, () => {
55
- it('should handle error state', () => {
56
- state.reviewsByHash[hash].isFetching = true;
57
- state = reducers(state, {
58
- type: ERROR_REVIEWS,
59
- hash
60
- });
61
- analyzeReceivedState(state);
62
- expect(state.reviewsByHash[hash].expires).toBe(0);
63
- });
64
- });
65
- });
66
- describe('ReviewsByProductId', () => {
67
- let state = {};
68
- describe(REQUEST_PRODUCT_REVIEWS, () => {
69
- it('should manipulate state when REQUEST_REVIEWS', () => {
70
- state = reducers(state, {
71
- type: REQUEST_PRODUCT_REVIEWS,
72
- productId: 'foo'
73
- });
74
- expect(state.reviewsByProductId.foo).toEqual({
75
- expires: 0,
76
- isFetching: true
77
- });
78
- });
79
- });
80
- describe(RECEIVE_PRODUCT_REVIEWS, () => {
81
- it('should manipulate state when receive reviews', () => {
82
- state = reducers(state, {
83
- type: RECEIVE_PRODUCT_REVIEWS,
84
- productId: 'foo',
85
- reviews: mockedReviews,
86
- totalReviewCount
87
- });
88
- expect(state.reviewsByProductId.foo.reviews.length).toBe(mockedReviews.length);
89
- });
90
- it('should replace reviews on another call when received more', () => {
91
- state = reducers(state, {
92
- type: RECEIVE_PRODUCT_REVIEWS,
93
- productId: 'foo',
94
- reviews: moreMockedReviews,
95
- totalReviewCount
96
- });
97
- expect(state.reviewsByProductId.foo.reviews.length).toBe(moreMockedReviews.length);
98
- });
99
- });
100
- describe(ERROR_PRODUCT_REVIEWS, () => {
101
- it('should handle error state', () => {
102
- state.reviewsByProductId.foo.isFetching = true;
103
- state = reducers(state, {
104
- type: ERROR_PRODUCT_REVIEWS,
105
- productId: 'foo'
106
- });
107
- expect(state.reviewsByProductId.foo.isFetching).toBe(false);
108
- });
109
- });
110
- });
111
- describe('userReviewsByProductId', () => {
112
- let state = {};
113
- const review = {
114
- id: 'id',
115
- one: 1,
116
- two: {}
117
- };
118
- const reviewWithProductId = {
119
- ...review,
120
- productId: 'foo'
121
- };
122
- describe(REQUEST_USER_REVIEW, () => {
123
- it('should handle request state', () => {
124
- state = reducers(state, {
125
- type: REQUEST_USER_REVIEW,
126
- productId: 'foo'
127
- });
128
- expect(state.userReviewsByProductId.foo.isFetching).toBe(true);
129
- expect(state.userReviewsByProductId.foo.review).toEqual('');
130
- });
131
- });
132
- describe(RECEIVE_USER_REVIEW, () => {
133
- it('should handle receive state', () => {
134
- state = reducers(state, {
135
- type: RECEIVE_USER_REVIEW,
136
- productId: 'foo',
137
- review
138
- });
139
- expect(state.userReviewsByProductId.foo.isFetching).toBe(false);
140
- expect(state.userReviewsByProductId.foo.review).toEqual('id');
141
- });
142
- });
143
- describe(ERROR_USER_REVIEW, () => {
144
- it('should handle receive state', () => {
145
- state = reducers(state, {
146
- type: ERROR_USER_REVIEW,
147
- productId: 'foo'
148
- });
149
- expect(typeof state.userReviewsByProductId.foo).toBe('undefined');
150
- });
151
- });
152
- describe(RECEIVE_USER_REVIEW, () => {
153
- it('should handle receive state', () => {
154
- state = reducers(state, {
155
- type: RECEIVE_USER_REVIEW,
156
- productId: 'foo',
157
- review: reviewWithProductId
158
- });
159
- expect(state.userReviewsByProductId.foo.isFetching).toBe(false);
160
- expect(state.userReviewsByProductId.foo.review).toEqual('id');
161
- });
162
- });
163
- describe(REQUEST_SUBMIT_REVIEW, () => {
164
- it('should handle request state', () => {
165
- state = reducers(state, {
166
- type: REQUEST_SUBMIT_REVIEW,
167
- review: {
168
- ...review,
169
- productId: 'foo'
170
- }
171
- });
172
- expect(state.userReviewsByProductId.foo.isFetching).toBe(true);
173
- expect(state.userReviewsByProductId.foo.review).toEqual('id');
174
- });
175
- });
176
- describe(RECEIVE_SUBMIT_REVIEW, () => {
177
- it('should handle receive state', () => {
178
- reviewWithProductId.one = 'one';
179
- state = reducers(state, {
180
- type: RECEIVE_SUBMIT_REVIEW,
181
- review: reviewWithProductId
182
- });
183
- expect(state.userReviewsByProductId.foo.isFetching).toBe(false);
184
- expect(state.userReviewsByProductId.foo.review).toEqual('id');
185
- expect(state.reviewsById[reviewWithProductId.id]).toEqual(reviewWithProductId);
186
- });
187
- });
188
- describe(ERROR_SUBMIT_REVIEW, () => {
189
- it('should handle receive state', () => {
190
- state = reducers(state, {
191
- type: ERROR_SUBMIT_REVIEW,
192
- productId: 'foo'
193
- });
194
- expect(typeof state.userReviewsByProductId.foo).toBe('undefined');
195
- });
196
- });
197
- describe(RESET_SUBMIT_REVIEW, () => {
198
- it('should handle receive state', () => {
199
- state = reducers(state, {
200
- type: RESET_SUBMIT_REVIEW,
201
- productId: 'foo',
202
- review: {
203
- productId: 'foo',
204
- one: '1'
205
- }
206
- });
207
- expect(state.userReviewsByProductId.foo.isFetching).toBe(false);
208
- expect(state.userReviewsByProductId.foo).toEqual({
209
- isFetching: false
210
- });
211
- });
212
- });
213
- });
214
- });
@@ -1,100 +0,0 @@
1
- import _cloneDeep from "lodash/cloneDeep";
2
- import { getProductReviews, getProductReviewsExcerpt, getReviewsTotalCount, getCurrentReviewCount, getReviewsFetchingState, getProductReviewCount, getUserReviewForProduct, getDefaultAuthorName } from "./index";
3
- import { REVIEW_PREVIEW_COUNT } from "../constants";
4
- import { emptyState, finalState, testReviews } from "./mock";
5
- describe('Reviews selectors', () => {
6
- const propsProductId = {
7
- productId: '9209597131'
8
- };
9
- const propsEmpty = {
10
- productId: null
11
- };
12
- describe('getProductReviews', () => {
13
- it('should return reviews when reviews are available', () => {
14
- const reviews = getProductReviews(finalState, propsProductId);
15
- expect(reviews).toEqual(testReviews);
16
- });
17
- it('should return empty array when state has no reviews for current product', () => {
18
- const state = _cloneDeep(finalState);
19
- const reviews = getProductReviews(state, propsEmpty);
20
- expect(reviews).toEqual([]);
21
- });
22
- it('should return empty array when state is empty', () => {
23
- const reviews = getProductReviews(emptyState, propsProductId);
24
- expect(reviews).toEqual([]);
25
- });
26
- });
27
- describe('getProductReviewsExcerpt', () => {
28
- it('should return product reviews when reviews are available', () => {
29
- const reviews = getProductReviewsExcerpt(finalState, propsProductId);
30
- expect(reviews).toEqual(testReviews.slice(0, REVIEW_PREVIEW_COUNT));
31
- });
32
- it('should return null when state has no reviews for current product', () => {
33
- const state = _cloneDeep(finalState);
34
- const reviews = getProductReviewsExcerpt(state, propsEmpty);
35
- expect(reviews).toBe(null);
36
- });
37
- it('should return null when state has no reviews for current product', () => {
38
- const reviews = getProductReviewsExcerpt(emptyState, propsProductId);
39
- expect(reviews).toBe(null);
40
- });
41
- });
42
- describe('getReviewsTotalCount', () => {
43
- it('should return null when no reviews are available', () => {
44
- const totalCount = getReviewsTotalCount(emptyState, propsProductId);
45
- expect(totalCount).toBe(null);
46
- });
47
- it('should return number when reviews are available', () => {
48
- const totalCount = getReviewsTotalCount(finalState, propsProductId);
49
- expect(totalCount).toBeGreaterThan(1);
50
- });
51
- });
52
- describe('getCurrentReviewCount', () => {
53
- it('should return null when no reviews are available', () => {
54
- const totalCount = getCurrentReviewCount(emptyState, propsProductId);
55
- expect(totalCount).toBe(null);
56
- });
57
- it('should return number when reviews are available', () => {
58
- const totalCount = getCurrentReviewCount(finalState, propsProductId);
59
- expect(totalCount).toBeGreaterThan(1);
60
- });
61
- });
62
- describe('getReviewsFetchingState', () => {
63
- it('should return fetching state', () => {
64
- const result = getReviewsFetchingState(finalState, propsProductId);
65
- expect(result).toEqual(false);
66
- });
67
- });
68
- describe('getProductReviewCount', () => {
69
- it('should return review count', () => {
70
- const result = getProductReviewCount(finalState, propsProductId);
71
- expect(result).toBe(finalState.reviews.reviewsByProductId[9209597131].totalReviewCount);
72
- });
73
- it('should return null when there is no reviews', () => {
74
- const result = getProductReviewCount(emptyState, propsProductId);
75
- expect(result).toBe(null);
76
- });
77
- });
78
- describe('getUserReviewForProduct', () => {
79
- it('should return user review', () => {
80
- const result = getUserReviewForProduct(finalState, propsProductId);
81
- expect(result).toEqual({
82
- ...finalState.reviews.reviewsById[1]
83
- });
84
- });
85
- it('should return empty object when no user review is available', () => {
86
- const result = getUserReviewForProduct(emptyState, propsProductId);
87
- expect(result).toEqual({});
88
- });
89
- });
90
- describe('getDefaultAuthorName', () => {
91
- it('should return author name when user is logged in', () => {
92
- const result = getDefaultAuthorName(finalState, propsProductId);
93
- expect(result).toBe('Foo Bar');
94
- });
95
- it('should return empty string, when user it not logged in', () => {
96
- const result = getDefaultAuthorName(emptyState, propsProductId);
97
- expect(result).toBe('');
98
- });
99
- });
100
- });
@@ -1,26 +0,0 @@
1
- import "core-js/modules/es.array.includes.js";
2
- import * as actionTypes from "../constants";
3
- import * as subjects from "./index";
4
- const subjectActionsTypes = {
5
- requestReviewSubmit$: [actionTypes.REQUEST_SUBMIT_REVIEW],
6
- responseReviewSubmit$: [actionTypes.RECEIVE_SUBMIT_REVIEW, actionTypes.ERROR_SUBMIT_REVIEW, actionTypes.RESET_SUBMIT_REVIEW],
7
- successReviewSubmit$: [actionTypes.RECEIVE_SUBMIT_REVIEW],
8
- errorReviewSubmit$: [actionTypes.ERROR_SUBMIT_REVIEW, actionTypes.RESET_SUBMIT_REVIEW]
9
- };
10
- describe.skip('Reviews streams', () => {
11
- it('should filter correctly', () => {
12
- const possibleSubjects = Object.keys(subjects);
13
- Object.keys(actionTypes).forEach(typeName => {
14
- const type = actionTypes[typeName];
15
- possibleSubjects.forEach(subjectName => {
16
- const result = subjects[subjectName].operator.predicate({
17
- action: {
18
- type
19
- }
20
- });
21
- const shouldBe = subjectActionsTypes[subjectName].includes(type);
22
- expect(result).toBe(shouldBe);
23
- });
24
- });
25
- });
26
- });
@@ -1,19 +0,0 @@
1
- import removeHighlightingPlaceholders from "./removeHighlightingPlaceholders";
2
- describe('search/helpers', () => {
3
- describe('removeHighlightingPlaceholers test', () => {
4
- it('should not change string without placeholders', () => {
5
- const result = removeHighlightingPlaceholders(['foo', 'bar']);
6
- expect(result[0]).toBe('foo');
7
- });
8
- it('should remove $start$ and $end$', () => {
9
- const testArray = ['$start$foo$end$', '$start$$end$', '$end$$start$', '$start$foo$end$'];
10
- const result = removeHighlightingPlaceholders(testArray);
11
- result.forEach((item, key) => {
12
- expect(item.indexOf('start')).toBe(-1);
13
- expect(item.indexOf('end')).toBe(-1);
14
- expect(item.indexOf('$')).toBe(-1);
15
- expect(item.length).toBe(Math.max(testArray[key].length - 12, 0));
16
- });
17
- });
18
- });
19
- });