@capillarytech/creatives-library 8.0.114-alpha.2 → 8.0.115

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.
@@ -7,6 +7,7 @@ import { mountWithIntl, shallowWithIntl } from '../../../../app/helpers/intl-enz
7
7
  import { Whatsapp } from '../index';
8
8
  import { mockData } from './mockData';
9
9
  import * as constants from '../constants';
10
+ import { mediaTypeOptions, WHATSAPP_CATEGORIES, HOST_GUPSHUP, HOST_TWILIO } from '../constants';
10
11
 
11
12
 
12
13
 
@@ -283,6 +284,38 @@ describe('Creatives Whatsapp test1/>', () => {
283
284
  renderedComponent.update();
284
285
  expect(renderedComponent).toMatchSnapshot();
285
286
  });
287
+ it("check for carousel render", () => {
288
+ renderHelper({}, true, accountData2);
289
+ renderedComponent
290
+ .find('CapSelect#select-whatsapp-category')
291
+ .props()
292
+ .onChange('MARKETING');
293
+ renderedComponent
294
+ .find('CapSelect#select-whatsapp-language')
295
+ .props()
296
+ .onChange('en');
297
+ expect(renderedComponent).toMatchSnapshot();
298
+ renderHelper({}, true, accountData3);
299
+ renderedComponent
300
+ .find('CapSelect#select-whatsapp-category')
301
+ .props()
302
+ .onChange('MARKETING');
303
+ renderedComponent
304
+ .find('CapSelect#select-whatsapp-language')
305
+ .props()
306
+ .onChange('en');
307
+ expect(renderedComponent).toMatchSnapshot();
308
+ renderHelper({}, true, accountData4);
309
+ renderedComponent
310
+ .find('CapSelect#select-whatsapp-category')
311
+ .props()
312
+ .onChange('MARKETING');
313
+ renderedComponent
314
+ .find('CapSelect#select-whatsapp-language')
315
+ .props()
316
+ .onChange('en');
317
+ expect(renderedComponent).toMatchSnapshot();
318
+ })
286
319
  });
287
320
 
288
321
  describe('Creatives Whatsapp test2/>', () => {
@@ -488,3 +521,58 @@ describe('Creatives Whatsapp test2/>', () => {
488
521
  expect(renderedComponent).toMatchSnapshot();
489
522
  });
490
523
  });
524
+
525
+ // --- UNIT TESTS FOR mediaTypeOptions ---
526
+ describe('mediaTypeOptions', () => {
527
+ it('should include CAROUSEL when category is MARKETING and host is HOST_GUPSHUP', () => {
528
+ const options = mediaTypeOptions({
529
+ host: HOST_GUPSHUP,
530
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
531
+ });
532
+ const hasCarousel = options.some(
533
+ (opt) => Array.isArray(opt)
534
+ ? opt.some((o) => o.key === 'CAROUSEL')
535
+ : opt.key === 'CAROUSEL'
536
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
537
+ expect(hasCarousel).toBe(true);
538
+ });
539
+
540
+ it('should NOT include CAROUSEL when category is MARKETING and host is NOT HOST_GUPSHUP', () => {
541
+ const options = mediaTypeOptions({
542
+ host: 'karixwhatsappbulk',
543
+ templateCategory: WHATSAPP_CATEGORIES.marketing,
544
+ });
545
+ const hasCarousel = options.some(
546
+ (opt) => Array.isArray(opt)
547
+ ? opt.some((o) => o.key === 'CAROUSEL')
548
+ : opt.key === 'CAROUSEL'
549
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
550
+ expect(hasCarousel).toBe(false);
551
+ });
552
+
553
+ it('should NOT include CAROUSEL when category is NOT MARKETING and host is HOST_GUPSHUP', () => {
554
+ const options = mediaTypeOptions({
555
+ host: HOST_GUPSHUP,
556
+ templateCategory: WHATSAPP_CATEGORIES.utility,
557
+ });
558
+ const hasCarousel = options.some(
559
+ (opt) => Array.isArray(opt)
560
+ ? opt.some((o) => o.key === 'CAROUSEL')
561
+ : opt.key === 'CAROUSEL'
562
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
563
+ expect(hasCarousel).toBe(false);
564
+ });
565
+
566
+ it('should NOT include CAROUSEL when category is NOT MARKETING and host is NOT HOST_GUPSHUP', () => {
567
+ const options = mediaTypeOptions({
568
+ host: HOST_TWILIO,
569
+ templateCategory: WHATSAPP_CATEGORIES.utility,
570
+ });
571
+ const hasCarousel = options.some(
572
+ (opt) => Array.isArray(opt)
573
+ ? opt.some((o) => o.key === 'CAROUSEL')
574
+ : opt.key === 'CAROUSEL'
575
+ ) || options.flat().some((o) => o.key === 'CAROUSEL');
576
+ expect(hasCarousel).toBe(false);
577
+ });
578
+ });