@capillarytech/creatives-library 7.14.28 → 7.14.30

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.
@@ -0,0 +1,41 @@
1
+ import * as types from '../constants';
2
+ import * as actions from '../actions';
3
+
4
+ describe('Test whatsapp actions', () => {
5
+ it('has a type of TEMPLATE_CREATE_REQUEST action', () => {
6
+ const payload = {
7
+ name: 'template_name',
8
+ versions: {
9
+ base: {
10
+ content: {
11
+ whatsapp: {
12
+ category: 'TRANSACTIONAL',
13
+ languages: [
14
+ {
15
+ language: 'en',
16
+ content: 'gupshup template message',
17
+ },
18
+ ],
19
+ mediaType: 'TEXT',
20
+ varMapped: {},
21
+ templateEditor: false,
22
+ accountId: '2000222347',
23
+ accessToken: 'DTpZEh4VK',
24
+ hostName: 'gupshupwhatsappbulk',
25
+ },
26
+ },
27
+ },
28
+ },
29
+ type: 'WHATSAPP',
30
+ };
31
+ const expected = {
32
+ type: types.TEMPLATE_CREATE_REQUEST,
33
+ gupshupMediaFile: undefined,
34
+ payload,
35
+ callback: undefined,
36
+ };
37
+ expect(
38
+ actions.createWhatsappTemplate(undefined, payload, undefined),
39
+ ).toStrictEqual(expected);
40
+ });
41
+ });
@@ -31,6 +31,7 @@ describe('Creatives Whatsapp test1/>', () => {
31
31
  const accountData1 = mockData.accountData1;
32
32
  const accountData2 = mockData.accountData2;
33
33
  const accountData3 = mockData.accountData3;
34
+ const accountData4 = mockData.accountData4;
34
35
 
35
36
  const renderHelper = (args, isFullMode = true, accData = accountData1) => {
36
37
  renderedComponent = mountWithIntl(
@@ -69,6 +70,8 @@ describe('Creatives Whatsapp test1/>', () => {
69
70
  expect(renderedComponent).toMatchSnapshot();
70
71
  renderHelper({}, true, accountData3);
71
72
  expect(renderedComponent).toMatchSnapshot();
73
+ renderHelper({}, true, accountData4);
74
+ expect(renderedComponent).toMatchSnapshot();
72
75
  renderHelper({}, true, {});
73
76
  expect(renderedComponent).toMatchSnapshot();
74
77
  });
@@ -306,7 +309,7 @@ describe('Creatives Whatsapp test2/>', () => {
306
309
  constants.INITIAL_CTA_DATA = [];
307
310
  renderHelper({});
308
311
  let event = { target: { value: 'template_name' } };
309
- createWhatsappTemplate.mockImplementation((obj, callback) => {
312
+ createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
310
313
  callback();
311
314
  });
312
315
 
@@ -356,7 +359,7 @@ describe('Creatives Whatsapp test2/>', () => {
356
359
  ];
357
360
  renderHelper({});
358
361
  let event = { target: { value: 'template_name' } };
359
- createWhatsappTemplate.mockImplementation((obj, callback) => {
362
+ createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
360
363
  callback();
361
364
  });
362
365
 
@@ -416,7 +419,7 @@ describe('Creatives Whatsapp test2/>', () => {
416
419
  ];
417
420
  renderHelper({});
418
421
  let event = { target: { value: 'template_name' } };
419
- createWhatsappTemplate.mockImplementation((obj, callback) => {
422
+ createWhatsappTemplate.mockImplementation((undefined, obj, callback) => {
420
423
  callback();
421
424
  });
422
425
 
@@ -20,6 +20,14 @@ export const mockData = {
20
20
  test: 'test',
21
21
  },
22
22
  },
23
+ accountData4: {
24
+ selectedWhatsappAccount: {
25
+ name: 'gupshup_test',
26
+ sourceAccountIdentifier: '2000222347',
27
+ configs: { accessToken: 'DTpZEh4VK' },
28
+ hostName: 'gupshupwhatsappbulk',
29
+ },
30
+ },
23
31
  editData1: {
24
32
  templateDetails: {
25
33
  _id: '62034b4683c75608cf2404ec',
@@ -8,13 +8,13 @@ import { WHATSAPP } from '../CreativesContainer/constants';
8
8
  import {
9
9
  STATUS_OPTIONS,
10
10
  TWILIO_CATEGORY_OPTIONS,
11
- KARIX_CATEGORY_OPTIONS,
11
+ KARIX_GUPSHUP_CATEGORY_OPTIONS,
12
12
  WHATSAPP_STATUSES,
13
13
  PHONE_NUMBER,
14
14
  NONE,
15
15
  CTA,
16
16
  WHATSAPP_MEDIA_TYPES,
17
- HOST_KARIX,
17
+ HOST_TWILIO,
18
18
  SIZE_UNITS,
19
19
  } from '../Whatsapp/constants';
20
20
  import './styles.scss';
@@ -142,15 +142,13 @@ export const getWhatsappCta = (template) => {
142
142
  return renderArray;
143
143
  };
144
144
 
145
- export const getWhatsappCategory = (category, hostName) => {
146
- return (
147
- hostName === HOST_KARIX ? KARIX_CATEGORY_OPTIONS : TWILIO_CATEGORY_OPTIONS
145
+ export const getWhatsappCategory = (category, hostName) => (
146
+ hostName === HOST_TWILIO ? TWILIO_CATEGORY_OPTIONS : KARIX_GUPSHUP_CATEGORY_OPTIONS
148
147
  ).find((obj) => obj.value === category);
149
- };
150
148
 
151
149
  export const getWhatsappStatus = (status) => {
152
150
  if ([WHATSAPP_STATUSES.pending, WHATSAPP_STATUSES.unsubmitted].includes(status)) {
153
151
  status = WHATSAPP_STATUSES.awaitingApproval;
154
152
  }
155
153
  return STATUS_OPTIONS.find((obj) => obj.value === status);
156
- }
154
+ };