@capillarytech/creatives-library 8.0.182 → 8.0.183

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,11 +1,4 @@
1
- import {
2
- take,
3
- fork,
4
- cancel,
5
- takeLatest,
6
- call,
7
- } from 'redux-saga/effects';
8
- import { fromJS } from 'immutable';
1
+ import { take, fork, cancel, takeLatest } from 'redux-saga/effects';
9
2
  import { expectSaga } from 'redux-saga-test-plan';
10
3
  import * as matchers from 'redux-saga-test-plan/matchers';
11
4
  import { throwError } from 'redux-saga-test-plan/providers';
@@ -42,23 +35,21 @@ import {
42
35
  CREATE_CENTRAL_COMMS_META_ID_FAILURE,
43
36
  CREATE_CENTRAL_COMMS_META_ID_REQUEST,
44
37
  } from '../constants';
45
- // Mock data imports - these may not exist in the mockdata file
46
- // const { callback, error, error2, videoConfigData } = require('../../mockdata');
38
+ import { callback, error, error2, videoConfigData } from '../../mockdata';
47
39
  import { LOGOUT_FAILURE, LOGOUT_SUCCESS } from '../../../constants/unified';
48
- import { loyaltyTagProps } from '../../CreativesContainer/selectors';
49
40
 
50
- // Mock data definitions
51
- const callback = jest.fn();
52
- const error = new Error('Test error');
53
- const error2 = new Error('Test error 2');
54
- const videoConfigData = { videos: [] };
41
+
55
42
 
56
43
  describe('v2CapSagas', () => {
57
- it("should initialize all v2CapSagas-related watcher sagas without error", async () => expectSaga(v2CapSagas).run());
44
+ it("should initialize all v2CapSagas-related watcher sagas without error", async () => {
45
+ return expectSaga(v2CapSagas).run();
46
+ });
58
47
  });
59
48
 
60
49
  describe('capSagaLiquidEntity', () => {
61
- it("should initialize all capSagaLiquidEntity-related watcher sagas without error", () => expectSaga(capSagaLiquidEntity).run());
50
+ it("should initialize all capSagaLiquidEntity-related watcher sagas without error", () => {
51
+ return expectSaga(capSagaLiquidEntity).run();
52
+ });
62
53
  });
63
54
 
64
55
  describe('logoutFlow [Unit Test]', () => {
@@ -128,11 +119,13 @@ describe('loginFlow', () => {
128
119
  it('should handle the login flow', () => {
129
120
  const generator = loginFlow();
130
121
  const user = { username: 'testuser', password: 'password123' };
122
+ let task;
123
+
131
124
  // First iteration
132
125
  expect(generator.next().value).toEqual(take(LOGIN_REQUEST));
133
126
  expect(generator.next({ user }).value).toEqual(fork(authorize, user));
134
- const task = generator.next().value; // Assign the task value
135
- try {
127
+ task = generator.next().value; // Assign the task value
128
+ try{
136
129
  const logoutAction = { type: LOGOUT_REQUEST_V2 };
137
130
  const failureAction = { type: LOGIN_FAILURE };
138
131
 
@@ -142,9 +135,8 @@ describe('loginFlow', () => {
142
135
  expect(generator.next(failureAction).value).toEqual(take(LOGIN_REQUEST));
143
136
  expect(generator.next().value).toEqual(fork(authorize, user));
144
137
  expect(generator.next().done).toBe(true);
145
- } catch {
146
- // Handle any errors
147
138
  }
139
+ catch{}
148
140
  });
149
141
  });
150
142
 
@@ -152,7 +144,7 @@ describe("fetchSchemaForEntity", () => {
152
144
  it("handle success response from fetchSchemaForEntity", () => {
153
145
  expectSaga(fetchSchemaForEntity, {
154
146
  queryParams: {
155
- type: 'tags',
147
+ type: 'tags'
156
148
  },
157
149
  })
158
150
  .provide([
@@ -168,7 +160,7 @@ describe("fetchSchemaForEntity", () => {
168
160
  type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
169
161
  data: {},
170
162
  statusCode: '',
171
- entityType: 'tags',
163
+ entityType: 'tags'
172
164
  })
173
165
  .run();
174
166
  });
@@ -176,7 +168,7 @@ describe("fetchSchemaForEntity", () => {
176
168
  it("handle success response from fetchSchemaForEntity when metaEntities available", () => {
177
169
  expectSaga(fetchSchemaForEntity, {
178
170
  queryParams: {
179
- type: 'tags',
171
+ type: 'tags'
180
172
  },
181
173
  })
182
174
  .provide([
@@ -184,7 +176,7 @@ describe("fetchSchemaForEntity", () => {
184
176
  matchers.call.fn(api.fetchSchemaForEntity),
185
177
  {
186
178
  response: {
187
- metaEntities: [],
179
+ metaEntities: []
188
180
  },
189
181
  },
190
182
  ],
@@ -192,10 +184,10 @@ describe("fetchSchemaForEntity", () => {
192
184
  .put({
193
185
  type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
194
186
  data: {
195
- metaEntities: [],
187
+ metaEntities: []
196
188
  },
197
189
  statusCode: '',
198
- entityType: 'tags',
190
+ entityType: 'tags'
199
191
  })
200
192
  .run();
201
193
  });
@@ -206,7 +198,7 @@ describe("fetchSchemaForEntity", () => {
206
198
  [
207
199
  matchers.call.fn(api.fetchSchemaForEntity),
208
200
  {
209
- success: true,
201
+ success: true
210
202
  },
211
203
  ],
212
204
  ])
@@ -214,7 +206,7 @@ describe("fetchSchemaForEntity", () => {
214
206
  type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
215
207
  data: {},
216
208
  statusCode: '',
217
- entityType: '',
209
+ entityType: ''
218
210
  })
219
211
  .run();
220
212
  });
@@ -222,7 +214,7 @@ describe("fetchSchemaForEntity", () => {
222
214
  it("handle error response from fetchSchemaForEntity", () => {
223
215
  expectSaga(fetchSchemaForEntity, {
224
216
  queryParams: {
225
- type: 'tags',
217
+ type: 'tags'
226
218
  },
227
219
  })
228
220
  .provide([
@@ -236,566 +228,10 @@ describe("fetchSchemaForEntity", () => {
236
228
  ])
237
229
  .put({
238
230
  type: GET_SCHEMA_FOR_ENTITY_FAILURE,
239
- error: 'Error in fetching tags',
231
+ error: 'Error in fetching tags'
240
232
  })
241
233
  .run();
242
234
  });
243
-
244
- // Loyalty Tag Props Test Cases
245
- describe('fetchSchemaForEntity with loyalty tag props', () => {
246
- it('should add loyaltyTagsParams when loyalty module is enabled and data exists', () => {
247
- const loyaltyTagPropsData = {
248
- isLoyaltyModule: true,
249
- loyaltyMetaData: { tagId: '123', tagName: 'Test Tag' },
250
- forwardedTags: { custom: 'value' },
251
- };
252
-
253
- const queryParams = {
254
- queryParams: {
255
- type: 'tags',
256
- },
257
- };
258
-
259
- const expectedQueryParams = {
260
- queryParams: {
261
- type: 'tags',
262
- loyaltyTagsParams: loyaltyTagPropsData,
263
- },
264
- };
265
-
266
- expectSaga(fetchSchemaForEntity, queryParams)
267
- .provide([
268
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
269
- [
270
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
271
- {
272
- success: true,
273
- response: {},
274
- },
275
- ],
276
- ])
277
- .put({
278
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
279
- data: {},
280
- statusCode: '',
281
- entityType: 'tags',
282
- })
283
- .run();
284
- });
285
-
286
- it('should not add loyaltyTagsParams when loyalty module is disabled', () => {
287
- const loyaltyTagPropsData = {
288
- isLoyaltyModule: false,
289
- loyaltyMetaData: { tagId: '123', tagName: 'Test Tag' },
290
- };
291
-
292
- const queryParams = {
293
- queryParams: {
294
- type: 'tags',
295
- },
296
- };
297
-
298
- expectSaga(fetchSchemaForEntity, queryParams)
299
- .provide([
300
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
301
- [
302
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
303
- {
304
- success: true,
305
- response: {},
306
- },
307
- ],
308
- ])
309
- .put({
310
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
311
- data: {},
312
- statusCode: '',
313
- entityType: 'tags',
314
- })
315
- .run();
316
- });
317
-
318
- it('should not add loyaltyTagsParams when loyaltyTagPropsData is null', () => {
319
- const loyaltyTagPropsData = null;
320
-
321
- const queryParams = {
322
- queryParams: {
323
- type: 'tags',
324
- },
325
- };
326
-
327
- expectSaga(fetchSchemaForEntity, queryParams)
328
- .provide([
329
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
330
- [
331
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
332
- {
333
- success: true,
334
- response: {},
335
- },
336
- ],
337
- ])
338
- .put({
339
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
340
- data: {},
341
- statusCode: '',
342
- entityType: 'tags',
343
- })
344
- .run();
345
- });
346
-
347
- it('should not add loyaltyTagsParams when loyaltyTagPropsData is undefined', () => {
348
- const loyaltyTagPropsData = undefined;
349
-
350
- const queryParams = {
351
- queryParams: {
352
- type: 'tags',
353
- },
354
- };
355
-
356
- expectSaga(fetchSchemaForEntity, queryParams)
357
- .provide([
358
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
359
- [
360
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
361
- {
362
- success: true,
363
- response: {},
364
- },
365
- ],
366
- ])
367
- .put({
368
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
369
- data: {},
370
- statusCode: '',
371
- entityType: 'tags',
372
- })
373
- .run();
374
- });
375
-
376
- it('should not add loyaltyTagsParams when loyaltyTagPropsData is empty object', () => {
377
- const loyaltyTagPropsData = {};
378
-
379
- const queryParams = {
380
- queryParams: {
381
- type: 'tags',
382
- },
383
- };
384
-
385
- expectSaga(fetchSchemaForEntity, queryParams)
386
- .provide([
387
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
388
- [
389
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
390
- {
391
- success: true,
392
- response: {},
393
- },
394
- ],
395
- ])
396
- .put({
397
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
398
- data: {},
399
- statusCode: '',
400
- entityType: 'tags',
401
- })
402
- .run();
403
- });
404
-
405
- it('should not add loyaltyTagsParams when isLoyaltyModule is false even if other data exists', () => {
406
- const loyaltyTagPropsData = {
407
- isLoyaltyModule: false,
408
- loyaltyMetaData: { tagId: '123', tagName: 'Test Tag' },
409
- forwardedTags: { custom: 'value' },
410
- };
411
-
412
- const queryParams = {
413
- queryParams: {
414
- type: 'tags',
415
- },
416
- };
417
-
418
- expectSaga(fetchSchemaForEntity, queryParams)
419
- .provide([
420
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
421
- [
422
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
423
- {
424
- success: true,
425
- response: {},
426
- },
427
- ],
428
- ])
429
- .put({
430
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
431
- data: {},
432
- statusCode: '',
433
- entityType: 'tags',
434
- })
435
- .run();
436
- });
437
-
438
- it('should not add loyaltyTagsParams when isLoyaltyModule is undefined', () => {
439
- const loyaltyTagPropsData = {
440
- loyaltyMetaData: { tagId: '123', tagName: 'Test Tag' },
441
- forwardedTags: { custom: 'value' },
442
- };
443
-
444
- const queryParams = {
445
- queryParams: {
446
- type: 'tags',
447
- },
448
- };
449
-
450
- expectSaga(fetchSchemaForEntity, queryParams)
451
- .provide([
452
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
453
- [
454
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
455
- {
456
- success: true,
457
- response: {},
458
- },
459
- ],
460
- ])
461
- .put({
462
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
463
- data: {},
464
- statusCode: '',
465
- entityType: 'tags',
466
- })
467
- .run();
468
- });
469
-
470
- it('should not add loyaltyTagsParams when isLoyaltyModule is null', () => {
471
- const loyaltyTagPropsData = {
472
- isLoyaltyModule: null,
473
- loyaltyMetaData: { tagId: '123', tagName: 'Test Tag' },
474
- forwardedTags: { custom: 'value' },
475
- };
476
-
477
- const queryParams = {
478
- queryParams: {
479
- type: 'tags',
480
- },
481
- };
482
-
483
- expectSaga(fetchSchemaForEntity, queryParams)
484
- .provide([
485
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
486
- [
487
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
488
- {
489
- success: true,
490
- response: {},
491
- },
492
- ],
493
- ])
494
- .put({
495
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
496
- data: {},
497
- statusCode: '',
498
- entityType: 'tags',
499
- })
500
- .run();
501
- });
502
-
503
- it('should add loyaltyTagsParams when isLoyaltyModule is true even with minimal data', () => {
504
- const loyaltyTagPropsData = {
505
- isLoyaltyModule: true,
506
- };
507
-
508
- const queryParams = {
509
- queryParams: {
510
- type: 'tags',
511
- },
512
- };
513
-
514
- const expectedQueryParams = {
515
- queryParams: {
516
- type: 'tags',
517
- loyaltyTagsParams: loyaltyTagPropsData,
518
- },
519
- };
520
-
521
- expectSaga(fetchSchemaForEntity, queryParams)
522
- .provide([
523
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
524
- [
525
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
526
- {
527
- success: true,
528
- response: {},
529
- },
530
- ],
531
- ])
532
- .put({
533
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
534
- data: {},
535
- statusCode: '',
536
- entityType: 'tags',
537
- })
538
- .run();
539
- });
540
-
541
- it('should handle loyalty tag props with complex nested data structure', () => {
542
- const loyaltyTagPropsData = {
543
- isLoyaltyModule: true,
544
- loyaltyMetaData: {
545
- tagId: '123',
546
- tagName: 'Test Tag',
547
- nested: {
548
- level1: {
549
- level2: 'deep value',
550
- },
551
- },
552
- },
553
- forwardedTags: {
554
- custom: 'value',
555
- array: [1, 2, 3],
556
- boolean: true,
557
- },
558
- };
559
-
560
- const queryParams = {
561
- queryParams: {
562
- type: 'tags',
563
- },
564
- };
565
-
566
- const expectedQueryParams = {
567
- queryParams: {
568
- type: 'tags',
569
- loyaltyTagsParams: loyaltyTagPropsData,
570
- },
571
- };
572
-
573
- expectSaga(fetchSchemaForEntity, queryParams)
574
- .provide([
575
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
576
- [
577
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
578
- {
579
- success: true,
580
- response: {},
581
- },
582
- ],
583
- ])
584
- .put({
585
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
586
- data: {},
587
- statusCode: '',
588
- entityType: 'tags',
589
- })
590
- .run();
591
- });
592
-
593
- it('should preserve existing queryParams when adding loyaltyTagsParams', () => {
594
- const loyaltyTagPropsData = {
595
- isLoyaltyModule: true,
596
- loyaltyMetaData: { tagId: '123' },
597
- };
598
-
599
- const queryParams = {
600
- queryParams: {
601
- type: 'tags',
602
- existingParam: 'existingValue',
603
- anotherParam: 123,
604
- },
605
- };
606
-
607
- const expectedQueryParams = {
608
- queryParams: {
609
- type: 'tags',
610
- existingParam: 'existingValue',
611
- anotherParam: 123,
612
- loyaltyTagsParams: loyaltyTagPropsData,
613
- },
614
- };
615
-
616
- expectSaga(fetchSchemaForEntity, queryParams)
617
- .provide([
618
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
619
- [
620
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
621
- {
622
- success: true,
623
- response: {},
624
- },
625
- ],
626
- ])
627
- .put({
628
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
629
- data: {},
630
- statusCode: '',
631
- entityType: 'tags',
632
- })
633
- .run();
634
- });
635
-
636
- it('should handle error response when loyalty module is enabled', () => {
637
- const loyaltyTagPropsData = {
638
- isLoyaltyModule: true,
639
- loyaltyMetaData: { tagId: '123' },
640
- };
641
-
642
- const queryParams = {
643
- queryParams: {
644
- type: 'tags',
645
- },
646
- };
647
-
648
- const expectedQueryParams = {
649
- queryParams: {
650
- type: 'tags',
651
- loyaltyTagsParams: loyaltyTagPropsData,
652
- },
653
- };
654
-
655
- expectSaga(fetchSchemaForEntity, queryParams)
656
- .provide([
657
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
658
- [
659
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
660
- {
661
- success: false,
662
- response: {},
663
- },
664
- ],
665
- ])
666
- .put({
667
- type: GET_SCHEMA_FOR_ENTITY_FAILURE,
668
- error: 'Error in fetching tags',
669
- })
670
- .run();
671
- });
672
-
673
- it('should add loyaltyTagsParams when isLoyaltyModule is true and loyaltyTagPropsData is empty object (truthy)', () => {
674
- const loyaltyTagPropsData = {
675
- isLoyaltyModule: true,
676
- // Empty object is still truthy, so it should add loyaltyTagsParams
677
- };
678
-
679
- const queryParams = {
680
- queryParams: {
681
- type: 'tags',
682
- },
683
- };
684
-
685
- const expectedQueryParams = {
686
- queryParams: {
687
- type: 'tags',
688
- loyaltyTagsParams: loyaltyTagPropsData,
689
- },
690
- };
691
-
692
- expectSaga(fetchSchemaForEntity, queryParams)
693
- .provide([
694
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
695
- [
696
- matchers.call.fn(api.fetchSchemaForEntity, expectedQueryParams),
697
- {
698
- success: true,
699
- response: {},
700
- },
701
- ],
702
- ])
703
- .put({
704
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
705
- data: {},
706
- statusCode: '',
707
- entityType: 'tags',
708
- })
709
- .run();
710
- });
711
-
712
- it('should handle the case where loyaltyTagPropsData is 0 (falsy)', () => {
713
- const loyaltyTagPropsData = 0; // Falsy value
714
-
715
- const queryParams = {
716
- queryParams: {
717
- type: 'tags',
718
- },
719
- };
720
-
721
- expectSaga(fetchSchemaForEntity, queryParams)
722
- .provide([
723
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
724
- [
725
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
726
- {
727
- success: true,
728
- response: {},
729
- },
730
- ],
731
- ])
732
- .put({
733
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
734
- data: {},
735
- statusCode: '',
736
- entityType: 'tags',
737
- })
738
- .run();
739
- });
740
-
741
- it('should handle the case where loyaltyTagPropsData is empty string (falsy)', () => {
742
- const loyaltyTagPropsData = ''; // Falsy value
743
-
744
- const queryParams = {
745
- queryParams: {
746
- type: 'tags',
747
- },
748
- };
749
-
750
- expectSaga(fetchSchemaForEntity, queryParams)
751
- .provide([
752
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
753
- [
754
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
755
- {
756
- success: true,
757
- response: {},
758
- },
759
- ],
760
- ])
761
- .put({
762
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
763
- data: {},
764
- statusCode: '',
765
- entityType: 'tags',
766
- })
767
- .run();
768
- });
769
-
770
- it('should handle the case where loyaltyTagPropsData is false (falsy)', () => {
771
- const loyaltyTagPropsData = false; // Falsy value
772
-
773
- const queryParams = {
774
- queryParams: {
775
- type: 'tags',
776
- },
777
- };
778
-
779
- expectSaga(fetchSchemaForEntity, queryParams)
780
- .provide([
781
- [matchers.select(loyaltyTagProps()), loyaltyTagPropsData],
782
- [
783
- matchers.call.fn(api.fetchSchemaForEntity, queryParams),
784
- {
785
- success: true,
786
- response: {},
787
- },
788
- ],
789
- ])
790
- .put({
791
- type: GET_SCHEMA_FOR_ENTITY_SUCCESS,
792
- data: {},
793
- statusCode: '',
794
- entityType: 'tags',
795
- })
796
- .run();
797
- });
798
- });
799
235
  });
800
236
 
801
237
  describe('getSupportVideoConfig saga', () => {
@@ -810,7 +246,7 @@ describe('getSupportVideoConfig saga', () => {
810
246
  success: true,
811
247
  status: 200,
812
248
  data: videoConfigData,
813
- },
249
+ }
814
250
  ],
815
251
  ])
816
252
  .put({
@@ -862,8 +298,9 @@ describe('watchForGetVideosConfig saga', () => {
862
298
  });
863
299
 
864
300
  describe('watchFetchSchemaForEntity saga', () => {
301
+
865
302
  it('test watchFetchSchemaForEntity', () => {
866
- const generator = watchFetchSchemaForEntity();
303
+ let generator = watchFetchSchemaForEntity();
867
304
  expect(generator.next().value).toEqual(
868
305
  takeLatest(GET_SCHEMA_FOR_ENTITY_REQUEST, fetchSchemaForEntity),
869
306
  );
@@ -873,8 +310,8 @@ describe('watchFetchSchemaForEntity saga', () => {
873
310
 
874
311
  describe('getLiquidTags saga', () => {
875
312
  it('handles successful API response', () => {
876
- const action = { data: 'templateContent', callback: () => {} };
877
- const result = { result: { errors: [{ message: "error in content" }] } };
313
+ const action = { data: 'templateContent', callback: () =>{}};
314
+ const result = { result :{errors: [{message: "error in content"}]} };
878
315
 
879
316
  expectSaga(getLiquidTags, action)
880
317
  .provide([
@@ -887,13 +324,13 @@ describe('getLiquidTags saga', () => {
887
324
  });
888
325
 
889
326
  it('handles successful API response for askAira', () => {
890
- const action = { data: 'templateContent', callback: () => {} };
891
- const result = { result: { errors: [{ message: "error in content" }] } };
327
+ const action = { data: 'templateContent', callback: () =>{}};
328
+ const result = { result :{errors: [{message: "error in content"}]} };
892
329
 
893
330
  expectSaga(getLiquidTags, action)
894
331
  .provide([
895
332
  [matchers.call.fn(api.getLiquidTags, 'templateContent'), result],
896
- [matchers.call.fn(api.askAiraForLiquid, { templateContent: 'templateContent', errorMessage: result?.result?.errors[0]?.message }), { result: { errors: [{ message: "Something went wrong" }] } }],
333
+ [matchers.call.fn(api.askAiraForLiquid, { templateContent: 'templateContent', errorMessage: result?.result?.errors[0]?.message }), {result: { errors: [{message: "Something went wrong"}]} }],
897
334
  ])
898
335
  .call.fn(action.callback, result)
899
336
  .put({ type: GET_LIQUID_TAGS_SUCCESS })
@@ -907,7 +344,7 @@ describe('getLiquidTags saga', () => {
907
344
  expectSaga(getLiquidTags, action)
908
345
  .provide([
909
346
  [matchers.call.fn(api.getLiquidTags, 'templateContent'), result],
910
- [matchers.call.fn(api.askAiraForLiquid, { templateContent: 'templateContent', errorMessage: result.errors[0].message }), { result: { errors: [{ message: "Something went wrong" }] } }],
347
+ [matchers.call.fn(api.askAiraForLiquid, { templateContent: 'templateContent', errorMessage: result.errors[0].message }), {result: { errors: [{message: "Something went wrong"}]} }],
911
348
  ])
912
349
  .not.call.fn(action.callback, result)
913
350
  .put({ type: GET_LIQUID_TAGS_FAILURE, error: true })
@@ -939,13 +376,13 @@ describe('getLiquidTags saga', () => {
939
376
  });
940
377
  it('handles error thrown during API call', () => {
941
378
  const action = { data: 'templateContent' };
942
- const apiError = new Error('API error');
379
+ const error = new Error('API error');
943
380
 
944
381
  expectSaga(getLiquidTags, action)
945
382
  .provide([
946
- [matchers.call.fn(api.getLiquidTags, 'templateContent'), throwError(apiError)],
383
+ [matchers.call.fn(api.getLiquidTags, 'templateContent'), throwError(error)],
947
384
  ])
948
- .put({ type: GET_LIQUID_TAGS_FAILURE, error: apiError })
385
+ .put({ type: GET_LIQUID_TAGS_FAILURE, error })
949
386
  .run();
950
387
  });
951
388
  });
@@ -961,15 +398,15 @@ describe('watchForGetLiquidTags saga', () => {
961
398
 
962
399
  describe('createCentralCommsMetaId saga', () => {
963
400
  const mockCallback = jest.fn();
964
-
401
+
965
402
  it('handles successful API response', () => {
966
- const action = {
967
- data: { templateId: '123456' },
968
- callback: mockCallback,
403
+ const action = {
404
+ data: { templateId: '123456' },
405
+ callback: mockCallback
969
406
  };
970
- const result = {
971
- status: { code: 200 },
972
- data: { id: '123456' },
407
+ const result = {
408
+ status: { code: 200 },
409
+ data: { id: '123456' }
973
410
  };
974
411
 
975
412
  expectSaga(createCentralCommsMetaId, action)
@@ -985,12 +422,12 @@ describe('createCentralCommsMetaId saga', () => {
985
422
  });
986
423
 
987
424
  it('handles unsuccessful API response', () => {
988
- const action = {
989
- data: { templateId: '123456' },
425
+ const action = {
426
+ data: { templateId: '123456' }
990
427
  };
991
- const result = {
428
+ const result = {
992
429
  status: { code: 400 },
993
- message: 'Failed to create meta ID',
430
+ message: 'Failed to create meta ID'
994
431
  };
995
432
 
996
433
  expectSaga(createCentralCommsMetaId, action)
@@ -1005,18 +442,18 @@ describe('createCentralCommsMetaId saga', () => {
1005
442
  });
1006
443
 
1007
444
  it('handles error thrown during API call', () => {
1008
- const action = {
1009
- data: { templateId: '123456' },
445
+ const action = {
446
+ data: { templateId: '123456' }
1010
447
  };
1011
- const apiError = new Error('API error');
448
+ const error = new Error('API error');
1012
449
 
1013
450
  expectSaga(createCentralCommsMetaId, action)
1014
451
  .provide([
1015
- [matchers.call.fn(api.createCentralCommsMetaId, action.data), throwError(apiError)],
452
+ [matchers.call.fn(api.createCentralCommsMetaId, action.data), throwError(error)],
1016
453
  ])
1017
454
  .put({
1018
455
  type: CREATE_CENTRAL_COMMS_META_ID_FAILURE,
1019
- error: apiError,
456
+ error,
1020
457
  })
1021
458
  .run();
1022
459
  });
@@ -1029,4 +466,4 @@ describe('watchMetaId saga', () => {
1029
466
  takeLatest(CREATE_CENTRAL_COMMS_META_ID_REQUEST, createCentralCommsMetaId),
1030
467
  );
1031
468
  });
1032
- });
469
+ });