@capillarytech/creatives-library 8.0.34-alpha.1 → 8.0.36
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/app.js +0 -1
- package/containers/App/test/saga.test.js +11 -0
- package/containers/Assets/Gallery/sagas.js +2 -1
- package/containers/Assets/Gallery/tests/saga.test.js +161 -0
- package/containers/Cap/tests/saga.test.js +8 -1
- package/containers/Dashboard/test/saga.test.js +9 -0
- package/containers/Ebill/test/saga.test.js +11 -0
- package/containers/Email/sagas.js +1 -1
- package/containers/Email/test/saga.test.js +278 -0
- package/containers/Line/Create/tests/saga.test.js +209 -0
- package/containers/Line/Edit/sagas.js +4 -4
- package/containers/Line/Edit/test/saga.test.js +164 -0
- package/containers/MobilePush/Create/index.js +1 -1
- package/containers/MobilePush/Create/test/saga.test.js +19 -0
- package/containers/MobilePush/Edit/index.js +1 -1
- package/containers/MobilePush/Edit/tests/saga.test.js +255 -0
- package/containers/Sms/Create/test/saga.test.js +12 -0
- package/containers/Sms/Edit/test/saga.test.js +13 -0
- package/containers/Templates/test/saga.test.js +244 -0
- package/containers/WeChat/MapTemplates/test/saga.test.js +159 -0
- package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +13 -0
- package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +12 -0
- package/hoc/test/WithReactRouterV3Compatibility.test.js +135 -0
- package/hoc/withReactRouterV3Compatibility.js +4 -4
- package/package.json +3 -3
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +4 -2
- package/tests/integration/TemplateCreation/api-response.js +10 -1
- package/tests/integration/TemplateCreation/msw-handler.js +3 -0
- package/utils/authWrapper.js +0 -6
- package/utils/tests/authWrapper.test.js +142 -0
- package/utils/tests/checkStore.test.js +72 -0
- package/utils/tests/customAuth.test.js +30 -0
- package/v2Components/NavigationBar/tests/saga.test.js +35 -0
- package/v2Containers/Assets/Gallery/sagas.js +1 -1
- package/v2Containers/Assets/Gallery/tests/saga.test.js +41 -0
- package/v2Containers/BeeEditor/test/saga.test.js +13 -0
- package/v2Containers/CallTask/test/saga.test.js +13 -0
- package/v2Containers/Cap/sagas.js +3 -3
- package/v2Containers/Cap/tests/Cap.test.js +2 -18
- package/v2Containers/Cap/tests/saga.test.js +73 -1
- package/v2Containers/CapFacebookPreview/tests/saga.test.js +13 -0
- package/v2Containers/Ebill/test/saga.test.js +13 -0
- package/v2Containers/Email/sagas.js +3 -2
- package/v2Containers/Email/tests/sagas.test.js +216 -0
- package/v2Containers/FTP/test/saga.test.js +12 -0
- package/v2Containers/Facebook/test/saga.test.js +171 -0
- package/v2Containers/InApp/tests/sagas.test.js +13 -0
- package/v2Containers/LanguageProvider/sagas.js +1 -1
- package/v2Containers/LanguageProvider/tests/saga.test.js +40 -0
- package/v2Containers/Line/Container/test/saga.test.js +228 -0
- package/v2Containers/MobilePush/Create/index.js +1 -1
- package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
- package/v2Containers/MobilePush/Edit/index.js +1 -1
- package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
- package/v2Containers/Rcs/tests/saga.test.js +13 -0
- package/v2Containers/Sms/Create/test/saga.test.js +8 -0
- package/v2Containers/Sms/Edit/test/saga.test.js +12 -0
- package/v2Containers/SmsTrai/Create/tests/saga.test.js +13 -0
- package/v2Containers/TagList/index.js +20 -8
- package/v2Containers/TagList/tests/TagList.test.js +11 -4
- package/v2Containers/TagList/tests/mockdata.js +4 -20
- package/v2Containers/Templates/sagas.js +7 -7
- package/v2Containers/Templates/tests/sagas.test.js +138 -0
- package/v2Containers/TemplatesV2/index.js +25 -51
- package/v2Containers/Viber/tests/saga.test.js +187 -0
- package/v2Containers/WeChat/MapTemplates/test/saga.test.js +160 -0
- package/v2Containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +12 -0
- package/v2Containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +13 -0
- package/v2Containers/Whatsapp/tests/saga.test.js +9 -1
- package/v2Containers/Zalo/tests/saga.test.js +8 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
|
|
1
2
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
3
|
import { takeLatest } from 'redux-saga/effects';
|
|
3
4
|
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
5
|
import { throwError } from 'redux-saga-test-plan/providers';
|
|
5
6
|
import * as types from '../constants';
|
|
6
7
|
import * as sagas from '../sagas';
|
|
8
|
+
import { v2EmailDuplicateTemplateSaga, v2EmailSagas } from '../sagas';
|
|
7
9
|
import {transformEmailTemplates} from '../../../utils/cdnTransformation';
|
|
10
|
+
import * as Api from '../../../services/api';
|
|
11
|
+
|
|
8
12
|
|
|
9
13
|
describe('transformEmailTemplate saga', () => {
|
|
10
14
|
it('handle valid response from api', () => {
|
|
@@ -62,3 +66,215 @@ describe('watchTransformEmailTemplate saga', () => {
|
|
|
62
66
|
expect(progress1.value).toEqual(mockTask);
|
|
63
67
|
});
|
|
64
68
|
});
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
describe('Email Templates Sagas', () => {
|
|
72
|
+
describe('createTemplate saga', () => {
|
|
73
|
+
it('should handle creating a template successfully', () => {
|
|
74
|
+
const template = { id: 1, name: 'New Template' };
|
|
75
|
+
const fakeResponse = {
|
|
76
|
+
success: true,
|
|
77
|
+
response: { id: 1, name: 'New Template', status: 'created' },
|
|
78
|
+
status: { code: 200 }
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
return expectSaga(sagas.createTemplate, template)
|
|
82
|
+
.provide([
|
|
83
|
+
[matchers.call.fn(Api.createEmailTemplate), fakeResponse],
|
|
84
|
+
])
|
|
85
|
+
.put({ type: types.CREATE_TEMPLATE_SUCCESS, data: fakeResponse.response, statusCode: 200, errorMsg: undefined })
|
|
86
|
+
.run();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should handle errors when creating a template fails', () => {
|
|
90
|
+
const template = { id: 1, name: 'New Template' };
|
|
91
|
+
const fakeError = new Error('Failed to create template');
|
|
92
|
+
|
|
93
|
+
return expectSaga(sagas.createTemplate, template)
|
|
94
|
+
.provide([
|
|
95
|
+
[matchers.call.fn(Api.createEmailTemplate), throwError(fakeError)],
|
|
96
|
+
])
|
|
97
|
+
.put({ type: types.CREATE_TEMPLATE_FAILURE, error: fakeError, errorMsg: undefined })
|
|
98
|
+
.run();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('getTemplateDetails saga', () => {
|
|
103
|
+
const id = 1;
|
|
104
|
+
|
|
105
|
+
it('should fetch template details successfully', () => {
|
|
106
|
+
const detailsResponse = { id: 1, name: 'Sample Template' };
|
|
107
|
+
|
|
108
|
+
return expectSaga(sagas.getTemplateDetails, id)
|
|
109
|
+
.provide([
|
|
110
|
+
[matchers.call.fn(Api.getTemplateDetails), { response: detailsResponse }]
|
|
111
|
+
])
|
|
112
|
+
.put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: detailsResponse })
|
|
113
|
+
.run();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should handle error when fetching template details fails', () => {
|
|
117
|
+
const error = new Error('Error fetching details');
|
|
118
|
+
|
|
119
|
+
return expectSaga(sagas.getTemplateDetails, id)
|
|
120
|
+
.provide([
|
|
121
|
+
[matchers.call.fn(Api.getTemplateDetails), throwError(error)]
|
|
122
|
+
])
|
|
123
|
+
.put({ type: types.GET_TEMPLATE_DETAILS_FAILURE, error })
|
|
124
|
+
.run();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
describe('uploadAsset saga', () => {
|
|
129
|
+
const file = new Blob();
|
|
130
|
+
const assetType = 'image';
|
|
131
|
+
const fileParams = { param1: 'value1' };
|
|
132
|
+
|
|
133
|
+
it('should handle successful asset upload', () => {
|
|
134
|
+
const uploadResponse = {
|
|
135
|
+
response: { asset: { id: 1, url: 'http://example.com/asset.jpg', metaInfo: { secure_file_path: 'path', file_size: 1024 } } },
|
|
136
|
+
status: { code: '200' }
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
|
|
140
|
+
.provide([
|
|
141
|
+
[matchers.call.fn(Api.uploadFile), uploadResponse]
|
|
142
|
+
])
|
|
143
|
+
.put({
|
|
144
|
+
type: types.UPLOAD_ASSET_SUCCESS,
|
|
145
|
+
data: uploadResponse.response.asset,
|
|
146
|
+
statusCode: '200'
|
|
147
|
+
})
|
|
148
|
+
.run();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should handle failure in asset upload', () => {
|
|
152
|
+
const error = new Error('Failed to upload asset');
|
|
153
|
+
|
|
154
|
+
return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
|
|
155
|
+
.provide([
|
|
156
|
+
[matchers.call.fn(Api.uploadFile), throwError(error)]
|
|
157
|
+
])
|
|
158
|
+
.put({ type: types.UPLOAD_ASSET_FAILURE, error })
|
|
159
|
+
.run();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
describe('Combined Sagas', () => {
|
|
167
|
+
it('v2EmailSagas should run specified sagas', () => {
|
|
168
|
+
return expectSaga(v2EmailSagas)
|
|
169
|
+
.run();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it('v2EmailDuplicateTemplateSaga should run the duplicate template sagas', () => {
|
|
173
|
+
return expectSaga(v2EmailDuplicateTemplateSaga)
|
|
174
|
+
.run();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
describe('duplicateTemplate saga', () => {
|
|
180
|
+
it('handles successful duplication with callback', () => {
|
|
181
|
+
const fakeResponse = {
|
|
182
|
+
status: { code: 200 },
|
|
183
|
+
response: { id: 2, name: 'Duplicated Template' }
|
|
184
|
+
};
|
|
185
|
+
const callback = jest.fn();
|
|
186
|
+
const payload = { id: 1, channel: 'email', callback };
|
|
187
|
+
|
|
188
|
+
return expectSaga(sagas.duplicateTemplate, payload)
|
|
189
|
+
.provide([
|
|
190
|
+
[matchers.call.fn(Api.duplicateTemplate, { id: 1, channel: 'email' }), fakeResponse],
|
|
191
|
+
])
|
|
192
|
+
.put({
|
|
193
|
+
type: types.DUPLICATE_TEMPLATE_SUCCESS,
|
|
194
|
+
data: fakeResponse.response,
|
|
195
|
+
statusCode: fakeResponse.status.code,
|
|
196
|
+
errorMsg: undefined
|
|
197
|
+
})
|
|
198
|
+
.run()
|
|
199
|
+
.then(() => {
|
|
200
|
+
expect(callback).toHaveBeenCalledWith(fakeResponse.response);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('handles API error', () => {
|
|
205
|
+
const payload = { id: 1, channel: 'email' };
|
|
206
|
+
const error = new Error('API error');
|
|
207
|
+
|
|
208
|
+
return expectSaga(sagas.duplicateTemplate, payload)
|
|
209
|
+
.provide([
|
|
210
|
+
[matchers.call.fn(Api.duplicateTemplate, { id: 1, channel: 'email' }), throwError(error)],
|
|
211
|
+
])
|
|
212
|
+
.put({
|
|
213
|
+
type: types.DUPLICATE_TEMPLATE_FAILURE,
|
|
214
|
+
error,
|
|
215
|
+
errorMsg: undefined
|
|
216
|
+
})
|
|
217
|
+
.run();
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('handles server-side error status', () => {
|
|
221
|
+
const fakeResponse = {
|
|
222
|
+
status: { code: 500 },
|
|
223
|
+
message: 'Internal server error'
|
|
224
|
+
};
|
|
225
|
+
const payload = { id: 1, channel: 'email' };
|
|
226
|
+
|
|
227
|
+
return expectSaga(sagas.duplicateTemplate, payload)
|
|
228
|
+
.provide([
|
|
229
|
+
[matchers.call.fn(Api.duplicateTemplate, { id: 1, channel: 'email' }), fakeResponse],
|
|
230
|
+
])
|
|
231
|
+
.put({
|
|
232
|
+
type: types.DUPLICATE_TEMPLATE_SUCCESS,
|
|
233
|
+
data: undefined,
|
|
234
|
+
statusCode: fakeResponse.status.code,
|
|
235
|
+
errorMsg: 'Internal server error'
|
|
236
|
+
})
|
|
237
|
+
.run();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('getAllAssets saga', () => {
|
|
242
|
+
it('handles successful duplication with callback', () => {
|
|
243
|
+
const fakeResponse = {
|
|
244
|
+
status: { code: 200 },
|
|
245
|
+
response: { id: 2, name: 'Duplicated Template' }
|
|
246
|
+
};
|
|
247
|
+
const callback = jest.fn();
|
|
248
|
+
const payload = {assetType: 'image', queryParams: { page: 1 }, callback };
|
|
249
|
+
|
|
250
|
+
return expectSaga(sagas.getAllAssets, payload)
|
|
251
|
+
.provide([
|
|
252
|
+
[matchers.call.fn(Api.getAllAssets, { id: 1, channel: 'email' }), fakeResponse],
|
|
253
|
+
])
|
|
254
|
+
.put({
|
|
255
|
+
type: types.GET_ALL_ASSETS_SUCCESS,
|
|
256
|
+
data: fakeResponse.response,
|
|
257
|
+
isReset: true
|
|
258
|
+
})
|
|
259
|
+
.run()
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('handles server-side error status', () => {
|
|
263
|
+
const fakeResponse = {
|
|
264
|
+
status: { code: 500 },
|
|
265
|
+
message: 'Internal server error'
|
|
266
|
+
};
|
|
267
|
+
const payload = {assetType: 'image', queryParams: { page: 1 } };
|
|
268
|
+
|
|
269
|
+
return expectSaga(sagas.getAllAssets, payload)
|
|
270
|
+
.provide([
|
|
271
|
+
[matchers.call.fn(Api.getAllAssets, { id: 1, channel: 'email' }), fakeResponse],
|
|
272
|
+
])
|
|
273
|
+
.put({
|
|
274
|
+
type: types.GET_ALL_ASSETS_SUCCESS,
|
|
275
|
+
data: undefined,
|
|
276
|
+
isReset: true
|
|
277
|
+
})
|
|
278
|
+
.run();
|
|
279
|
+
});
|
|
280
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
import { expectSaga } from "redux-saga-test-plan";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
v2FTPSagas,
|
|
6
|
+
} from "../sagas";
|
|
7
|
+
|
|
8
|
+
describe("v2FTPSagas Combined", () => {
|
|
9
|
+
it("should initialize all v2FTPSagas-related watcher sagas without error", () => {
|
|
10
|
+
return expectSaga(v2FTPSagas).run();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
+
|
|
3
|
+
import { throwError } from 'redux-saga-test-plan/providers';
|
|
4
|
+
import * as Api from '../../../services/api';
|
|
5
|
+
import * as types from '../constants';
|
|
6
|
+
import * as sagas from '../sagas';
|
|
7
|
+
import {v2FacebookSagas} from '../sagas';
|
|
8
|
+
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
9
|
+
|
|
10
|
+
describe('Facebook Ad Management Sagas', () => {
|
|
11
|
+
describe('fetchMarketingObjectives Saga', () => {
|
|
12
|
+
it('handles successful fetching of marketing objectives', () => {
|
|
13
|
+
const fakeResponse = {
|
|
14
|
+
data: [{ id: 1, name: 'Increase Reach' }],
|
|
15
|
+
errors: []
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return expectSaga(sagas.fetchMarketingObjectives)
|
|
19
|
+
.provide([
|
|
20
|
+
[matchers.call.fn(Api.getMarketingObjectives, 'FACEBOOK'), fakeResponse]
|
|
21
|
+
])
|
|
22
|
+
.put({
|
|
23
|
+
type: types.SET_MARKETING_OBJECTIVES_SUCCESS,
|
|
24
|
+
payload: fakeResponse.data,
|
|
25
|
+
})
|
|
26
|
+
.run();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('handles errors in fetching marketing objectives', () => {
|
|
30
|
+
const fakeResponse = {
|
|
31
|
+
errors: ['Error fetching data'],
|
|
32
|
+
data: null
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return expectSaga(sagas.fetchMarketingObjectives)
|
|
36
|
+
.provide([
|
|
37
|
+
[matchers.call.fn(Api.getMarketingObjectives, 'FACEBOOK'), throwError(new Error('Error'))]
|
|
38
|
+
])
|
|
39
|
+
.put({
|
|
40
|
+
type: types.SET_MARKETING_OBJECTIVES_FAILURE,
|
|
41
|
+
payload: new Error('Error'),
|
|
42
|
+
})
|
|
43
|
+
.run();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('getOrgOUs Saga', () => {
|
|
48
|
+
const orgID = '123';
|
|
49
|
+
|
|
50
|
+
it('handles successful fetching of org OUs', () => {
|
|
51
|
+
const fakeResponse = {
|
|
52
|
+
status: 200,
|
|
53
|
+
result: [{ id: 1, name: 'Org Unit One' }],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return expectSaga(sagas.getOrgOUs, { orgID })
|
|
57
|
+
.provide([
|
|
58
|
+
[matchers.call.fn(Api.getOrgOUs, { orgID }), fakeResponse]
|
|
59
|
+
])
|
|
60
|
+
.put({
|
|
61
|
+
type: types.GET_ORG_OU_LIST_SUCCESS,
|
|
62
|
+
payload: fakeResponse.result,
|
|
63
|
+
})
|
|
64
|
+
.run();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('handles failure in fetching org OUs', () => {
|
|
68
|
+
const error = new Error('Fetch failed');
|
|
69
|
+
|
|
70
|
+
return expectSaga(sagas.getOrgOUs, { orgID })
|
|
71
|
+
.provide([
|
|
72
|
+
[matchers.call.fn(Api.getOrgOUs, { orgID }), throwError(error)]
|
|
73
|
+
])
|
|
74
|
+
.put({
|
|
75
|
+
type: types.GET_ORG_OU_LIST_FAILURE,
|
|
76
|
+
payload: error,
|
|
77
|
+
})
|
|
78
|
+
.run();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('uploadFbAdAsset Saga', () => {
|
|
83
|
+
const file = { name: 'ad.mp4', assetType: 'video', videoData: { accessToken: 'abc123' } };
|
|
84
|
+
const assetType = 'video';
|
|
85
|
+
const fileParams = {};
|
|
86
|
+
|
|
87
|
+
it('handles successful asset upload', () => {
|
|
88
|
+
const uploadResponse = {
|
|
89
|
+
status: { code: 200 },
|
|
90
|
+
response: { asset: { id: 1, metaInfo: { secure_file_path: 'http://example.com/ad.mp4' } } }
|
|
91
|
+
};
|
|
92
|
+
const videoIdResponse = {
|
|
93
|
+
response: { id: 'video123' },
|
|
94
|
+
status: { isError: false }
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return expectSaga(sagas.uploadFbAdAsset, file, assetType, fileParams)
|
|
98
|
+
.provide([
|
|
99
|
+
[matchers.call.fn(Api.uploadFile, file, assetType, fileParams), uploadResponse],
|
|
100
|
+
[matchers.call.fn(Api.getFacebookVideoId, {
|
|
101
|
+
videoUrl: uploadResponse.response.asset.metaInfo.secure_file_path,
|
|
102
|
+
accessToken: file.videoData.accessToken,
|
|
103
|
+
actId: file.videoData.actId,
|
|
104
|
+
pageAccessToken: file.videoData.pageAccessToken,
|
|
105
|
+
pageId: file.videoData.pageId
|
|
106
|
+
}), videoIdResponse]
|
|
107
|
+
])
|
|
108
|
+
.put({
|
|
109
|
+
type: types.UPLOAD_FB_AD_ASSET_SUCCESS,
|
|
110
|
+
data: {...uploadResponse.response.asset, videoIdResponse: videoIdResponse.response},
|
|
111
|
+
statusCode: 200,
|
|
112
|
+
templateType: file.templateType,
|
|
113
|
+
})
|
|
114
|
+
.run();
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('handles failure in asset upload', () => {
|
|
118
|
+
const error = new Error('Upload failed');
|
|
119
|
+
|
|
120
|
+
return expectSaga(sagas.uploadFbAdAsset, file, assetType, fileParams)
|
|
121
|
+
.provide([
|
|
122
|
+
[matchers.call.fn(Api.uploadFile, file, assetType, fileParams), throwError(error)]
|
|
123
|
+
])
|
|
124
|
+
.put({
|
|
125
|
+
type: types.UPLOAD_FB_AD_ASSET_FAILURE,
|
|
126
|
+
error
|
|
127
|
+
})
|
|
128
|
+
.run();
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
// Test combined saga
|
|
134
|
+
describe('Combined v2FacebookSagas', () => {
|
|
135
|
+
it('should initialize all Facebook-related watcher sagas without error', () => {
|
|
136
|
+
return expectSaga(v2FacebookSagas)
|
|
137
|
+
.run();
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
describe('editTemplate Saga', () => {
|
|
145
|
+
const template = { id: 1, content: 'Updated Ad Content' };
|
|
146
|
+
const callback = jest.fn(); // Mock callback function
|
|
147
|
+
|
|
148
|
+
it('handles successful editing of a Facebook Ad template', () => {
|
|
149
|
+
const fakeResponse = {
|
|
150
|
+
response: { id: 1, name: 'Updated Ad' },
|
|
151
|
+
status: { code: 200 }
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
return expectSaga(sagas.editTemplate, { template, callback })
|
|
155
|
+
.provide([
|
|
156
|
+
[matchers.call.fn(Api.createFacebookADTemplate, { template }), fakeResponse]
|
|
157
|
+
])
|
|
158
|
+
.put({
|
|
159
|
+
type: types.EDIT_FACEBOOK_AD_TEMPLATE_SUCCESS,
|
|
160
|
+
data: fakeResponse.response,
|
|
161
|
+
statusCode: 200,
|
|
162
|
+
errorMsg: undefined
|
|
163
|
+
})
|
|
164
|
+
.run()
|
|
165
|
+
.then(() => {
|
|
166
|
+
expect(callback).toHaveBeenCalledWith(fakeResponse.response);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
});
|
|
@@ -6,6 +6,10 @@ import * as sagas from '../sagas';
|
|
|
6
6
|
import * as Api from '../../../services/api';
|
|
7
7
|
import * as types from '../constants';
|
|
8
8
|
import { INAPP } from '../../CreativesContainer/constants';
|
|
9
|
+
import {
|
|
10
|
+
v2InAppSagas,
|
|
11
|
+
} from "../sagas";
|
|
12
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
9
13
|
|
|
10
14
|
describe('test for uploadInAppAsset function', () => {
|
|
11
15
|
it('should dispatch UPLOAD_INAPP_ASSET_SUCCESS action with asset data, status code, and template type', () => {
|
|
@@ -392,3 +396,12 @@ describe('test for getTemplateDetails', () => {
|
|
|
392
396
|
expect(gen.next().value).toEqual(undefined);
|
|
393
397
|
});
|
|
394
398
|
});
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
describe("v2InAppSagas Combined", () => {
|
|
404
|
+
it("should initialize all v2InAppSagas-related watcher sagas without error", () => {
|
|
405
|
+
return expectSaga(v2InAppSagas).run();
|
|
406
|
+
});
|
|
407
|
+
});
|
|
@@ -2,7 +2,7 @@ import { takeLatest, take, all, cancel, call, put } from 'redux-saga/effects';
|
|
|
2
2
|
import * as Api from '../../services/api';
|
|
3
3
|
import * as types from './constants';
|
|
4
4
|
|
|
5
|
-
function* getLocizMessage(action) {
|
|
5
|
+
export function* getLocizMessage(action) {
|
|
6
6
|
try {
|
|
7
7
|
const result = yield call(Api.getLocizMessage, action.locale);
|
|
8
8
|
yield put({
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
+
import { call, put } from 'redux-saga/effects';
|
|
3
|
+
import { throwError } from 'redux-saga-test-plan/providers';
|
|
4
|
+
import { getLocizMessage } from '../sagas';
|
|
5
|
+
import * as api from '../../../services/api';
|
|
6
|
+
import * as types from '../constants';
|
|
7
|
+
|
|
8
|
+
describe('getLocizMessage saga', () => {
|
|
9
|
+
const locale = 'en-US';
|
|
10
|
+
const action = { locale };
|
|
11
|
+
|
|
12
|
+
it('handles successful API call', () => {
|
|
13
|
+
const response = { messages: { hello: "Hello" } }; // Example response structure
|
|
14
|
+
|
|
15
|
+
return expectSaga(getLocizMessage, action)
|
|
16
|
+
.provide([
|
|
17
|
+
[call(api.getLocizMessage, locale), response]
|
|
18
|
+
])
|
|
19
|
+
.put({
|
|
20
|
+
type: types.GET_LOCIZ_MESSAGE_SUCCESS,
|
|
21
|
+
data: response,
|
|
22
|
+
locale: locale,
|
|
23
|
+
})
|
|
24
|
+
.run();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('handles failure when API call fails', () => {
|
|
28
|
+
const error = new Error('Failed to fetch localization messages');
|
|
29
|
+
|
|
30
|
+
return expectSaga(getLocizMessage, action)
|
|
31
|
+
.provide([
|
|
32
|
+
[call(api.getLocizMessage, locale), throwError(error)]
|
|
33
|
+
])
|
|
34
|
+
.put({
|
|
35
|
+
type: types.GET_LOCIZ_MESSAGE_FAILURE,
|
|
36
|
+
data: error,
|
|
37
|
+
})
|
|
38
|
+
.run();
|
|
39
|
+
});
|
|
40
|
+
});
|