@capillarytech/creatives-library 7.17.35 → 7.17.37-alpha.0

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.
Files changed (46) hide show
  1. package/containers/Templates/actions.js +0 -5
  2. package/index.js +6 -0
  3. package/package.json +1 -1
  4. package/routes.js +5 -0
  5. package/services/api.js +6 -1
  6. package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +2 -1
  7. package/v2Containers/App/constants.js +1 -0
  8. package/v2Containers/CreativesContainer/SlideBoxContent.js +13 -0
  9. package/v2Containers/CreativesContainer/SlideBoxHeader.js +9 -6
  10. package/v2Containers/CreativesContainer/constants.js +1 -0
  11. package/v2Containers/CreativesContainer/index.scss +3 -0
  12. package/v2Containers/CreativesContainer/messages.js +8 -0
  13. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +6 -1
  14. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +58 -0
  15. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +18114 -88
  16. package/v2Containers/Templates/_templates.scss +20 -2
  17. package/v2Containers/Templates/actions.js +4 -3
  18. package/v2Containers/Templates/constants.js +2 -1
  19. package/v2Containers/Templates/index.js +326 -120
  20. package/v2Containers/Templates/messages.js +32 -8
  21. package/v2Containers/Templates/reducer.js +3 -1
  22. package/v2Containers/Templates/sagas.js +2 -2
  23. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +623 -43
  24. package/v2Containers/Templates/tests/actions.test.js +18 -0
  25. package/v2Containers/Templates/tests/index.test.js +52 -1
  26. package/v2Containers/Templates/tests/mockData.js +41 -1
  27. package/v2Containers/Templates/tests/reducer.test.js +50 -0
  28. package/v2Containers/Templates/tests/sagas.test.js +40 -2
  29. package/v2Containers/Templates/tests/selector.test.js +17 -0
  30. package/v2Containers/TemplatesV2/index.js +2 -2
  31. package/v2Containers/TemplatesV2/messages.js +4 -0
  32. package/v2Containers/Zalo/actions.js +17 -0
  33. package/v2Containers/Zalo/constants.js +56 -0
  34. package/v2Containers/Zalo/index.js +390 -0
  35. package/v2Containers/Zalo/index.scss +76 -0
  36. package/v2Containers/Zalo/messages.js +74 -0
  37. package/v2Containers/Zalo/reducer.js +57 -0
  38. package/v2Containers/Zalo/saga.js +35 -0
  39. package/v2Containers/Zalo/selectors.js +14 -0
  40. package/v2Containers/Zalo/tests/actions.test.js +20 -0
  41. package/v2Containers/Zalo/tests/index.test.js +127 -0
  42. package/v2Containers/Zalo/tests/mockData.js +11470 -0
  43. package/v2Containers/Zalo/tests/reducer.test.js +85 -0
  44. package/v2Containers/Zalo/tests/saga.test.js +115 -0
  45. package/v2Containers/Zalo/tests/selectors.test.js +52 -0
  46. package/v2Containers/mockdata.js +817 -680
@@ -0,0 +1,85 @@
1
+ import { fromJS } from "immutable";
2
+ import zaloReducer from "../reducer";
3
+ import * as actions from "../actions";
4
+ import {
5
+ ZALO_TEMPLATE_INFO_SUCCESS,
6
+ ZALO_TEMPLATE_INFO_ERROR,
7
+ ZALO_TEMPLATE_PREVIEW_INFO,
8
+ ZALO_TEMPLATE_PREVIEW_RESET,
9
+ REQUEST,
10
+ SUCCESS,
11
+ ERROR,
12
+ } from "../constants";
13
+ import { zaloTemplateInfoData } from "./mockData";
14
+
15
+
16
+ describe("zalo reducer", () => {
17
+ let state;
18
+ const action = {};
19
+ beforeEach(() => {
20
+ state = fromJS({
21
+ zaloTemplateInfoStatus: "",
22
+ zaloTemplateInfoValue: "",
23
+ zaloTemplateInfoError: "",
24
+ });
25
+ });
26
+
27
+ describe("Reducer : ZALO_TEMPLATE_INFO_REQUEST", () => {
28
+ it("should handle ZALO_TEMPLATE_INFO_REQUEST action", () => {
29
+ state = state
30
+ .set("zaloTemplateInfoStatus", REQUEST)
31
+ .set("zaloTemplateInfoValue", "")
32
+ .set("zaloTemplateInfoError", null);
33
+ const expectedResult = state;
34
+ expect(zaloReducer(state, actions.getTemplateInfoById({}))).toEqual(
35
+ expectedResult
36
+ );
37
+ });
38
+ it("should handle ZALO_TEMPLATE_INFO_SUCCESS action", () => {
39
+ action.type = ZALO_TEMPLATE_INFO_SUCCESS;
40
+ action.result = zaloTemplateInfoData.zaloTemplateInfoValue;
41
+ state = state
42
+ .set("zaloTemplateInfoStatus", SUCCESS)
43
+ .set("zaloTemplateInfoValue", action.result)
44
+ .set("zaloTemplateInfoError", null);
45
+ const expectedResult = state;
46
+ expect(zaloReducer(state, action)).toEqual(expectedResult);
47
+ });
48
+ it("should handle ZALO_TEMPLATE_INFO_ERROR action", () => {
49
+ action.type = ZALO_TEMPLATE_INFO_ERROR;
50
+ action.error = {};
51
+ state = state
52
+ .set("zaloTemplateInfoStatus", ERROR)
53
+ .set("zaloTemplateInfoError", action.error);
54
+ const expectedResult = state;
55
+ expect(zaloReducer(state, action)).toEqual(expectedResult);
56
+ });
57
+
58
+ it("should handle ZALO_TEMPLATE_PREVIEW_INFO action", () => {
59
+ action.type = ZALO_TEMPLATE_PREVIEW_INFO;
60
+ action.result = zaloTemplateInfoData.zaloTemplateInfoValue;
61
+ state = state
62
+ .set("zaloTemplateInfoStatus", SUCCESS)
63
+ .set("zaloTemplatePreviewData", action.result)
64
+ .set("zaloTemplateInfoError", null);
65
+ const expectedResult = state;
66
+ expect(zaloReducer(state, action)).toEqual(expectedResult);
67
+ });
68
+
69
+ it("should handle ZALO_TEMPLATE_PREVIEW_RESET action", () => {
70
+ action.type = ZALO_TEMPLATE_PREVIEW_RESET;
71
+ state = state
72
+ .set("zaloTemplateInfoStatus", REQUEST)
73
+ .set("zaloTemplatePreviewData", "")
74
+ .set("zaloTemplateInfoError", null);
75
+ const expectedResult = state;
76
+ expect(zaloReducer(state, action)).toEqual(expectedResult);
77
+ });
78
+
79
+ it("should handle default action", () => {
80
+ action.type = "deafult_action";
81
+ const expectedResult = state;
82
+ expect(zaloReducer(state, action)).toEqual(expectedResult);
83
+ });
84
+ });
85
+ });
@@ -0,0 +1,115 @@
1
+ import { expectSaga, testSaga } from "redux-saga-test-plan";
2
+ import * as matchers from "redux-saga-test-plan/matchers";
3
+ import { takeLatest } from "redux-saga/effects";
4
+ import { getTemplateInfoById, watchForGetTemplateInfoById } from "../saga";
5
+ import {
6
+ ZALO_TEMPLATE_INFO_SUCCESS,
7
+ ZALO_TEMPLATE_INFO_ERROR,
8
+ ZALO_TEMPLATE_INFO_REQUEST,
9
+ ZALO_TEMPLATE_PREVIEW_INFO,
10
+ } from "../constants";
11
+ import * as Api from "../../../services/api";
12
+
13
+ describe("zalo saga", () => {
14
+ const error = new Error("error");
15
+ describe("zalo test saga", () => {
16
+ it("handle success response from getTemplateInfoById", () => {
17
+ expectSaga(getTemplateInfoById, {
18
+ payload: {
19
+ id: 10234,
20
+ username: "capillary_zns",
21
+ oa_id: "kfhksda7326kjs",
22
+ token: "tyfdusafhdsk783687342678",
23
+ },
24
+ })
25
+ .provide([
26
+ [
27
+ matchers.call.fn(Api.getTemplateInfoById),
28
+ {
29
+ success: true,
30
+ result: [],
31
+ },
32
+ ],
33
+ ])
34
+ .put({
35
+ type: ZALO_TEMPLATE_INFO_SUCCESS,
36
+ result: {},
37
+ })
38
+ .run();
39
+ });
40
+
41
+ it("handle success response from getTemplateInfoById for preview", () => {
42
+ expectSaga(getTemplateInfoById, {
43
+ payload: {
44
+ id: 10234,
45
+ username: "capillary_zns",
46
+ oa_id: "kfhksda7326kjs",
47
+ token: "tyfdusafhdsk783687342678",
48
+ preview: true,
49
+ },
50
+ })
51
+ .provide([
52
+ [
53
+ matchers.call.fn(Api.getTemplateInfoById),
54
+ {
55
+ success: true,
56
+ result: [],
57
+ },
58
+ ],
59
+ ])
60
+ .put({
61
+ type: ZALO_TEMPLATE_PREVIEW_INFO,
62
+ result: {},
63
+ })
64
+ .run();
65
+ });
66
+
67
+ it("handle success response from getTemplateInfoById when response is not present", () => {
68
+ expectSaga(getTemplateInfoById, {
69
+ payload: {},
70
+ })
71
+ .provide([
72
+ [
73
+ matchers.call.fn(Api.getTemplateInfoById),
74
+ {
75
+ success: true,
76
+ },
77
+ ],
78
+ ])
79
+ .put({
80
+ type: ZALO_TEMPLATE_INFO_SUCCESS,
81
+ })
82
+ .run();
83
+ });
84
+ it("handle failure response from getTemplateInfoById", () => {
85
+ expectSaga(getTemplateInfoById, {
86
+ payload: {},
87
+ })
88
+ .provide([
89
+ [
90
+ matchers.call.fn(Api.getTemplateInfoById),
91
+ {
92
+ success: false,
93
+ },
94
+ ],
95
+ ])
96
+ .put({
97
+ type: ZALO_TEMPLATE_INFO_ERROR,
98
+ })
99
+ .run();
100
+ });
101
+
102
+ it("handles error thrown", () => {
103
+ testSaga(getTemplateInfoById, {}).next().throw(error).next().isDone();
104
+ });
105
+ });
106
+
107
+ describe("watchForGetTemplateInfoById saga", () => {
108
+ const generator = watchForGetTemplateInfoById();
109
+ it("should call watchers functions", async () => {
110
+ expect(generator.next().value).toEqual(
111
+ takeLatest(ZALO_TEMPLATE_INFO_REQUEST, getTemplateInfoById)
112
+ );
113
+ });
114
+ });
115
+ });
@@ -0,0 +1,52 @@
1
+ import { fromJS } from "immutable";
2
+ import { makeSelectZalo, selectZaloDomain } from "../selectors";
3
+ import { zaloTemplateInfoData } from "./mockData";
4
+
5
+ describe("makeSelectZalo", () => {
6
+ it("returns the expected object with default values when substate is empty", () => {
7
+ // Arrange
8
+ const state = fromJS({ zalo: {} });
9
+ const expected = {
10
+ zaloTemplateInfoStatus: undefined,
11
+ zaloTemplateInfoValue: undefined,
12
+ zaloTemplateInfoError: undefined,
13
+ zaloTemplatePreviewData: undefined,
14
+ };
15
+ const selector = makeSelectZalo();
16
+
17
+ // Act
18
+ const result = selector(state);
19
+
20
+ // Assert
21
+ expect(result).toEqual(expected);
22
+ });
23
+
24
+ it("returns the expected object when substate has values", () => {
25
+ // Arrange
26
+ const state = fromJS({
27
+ zalo: zaloTemplateInfoData,
28
+ });
29
+ const expected = {
30
+ zaloTemplateInfoStatus: "success",
31
+ zaloTemplateInfoValue: fromJS(zaloTemplateInfoData.zaloTemplateInfoValue),
32
+ zaloTemplateInfoError: null,
33
+ zaloTemplatePreviewData: undefined,
34
+ };
35
+ const selector = makeSelectZalo();
36
+
37
+ // Act
38
+ const result = selector(state);
39
+
40
+ // Assert
41
+ expect(result).toEqual(expected);
42
+ });
43
+
44
+ it("returns the expected object with default values when substate is empty", () => {
45
+ // Arrange
46
+ const state = fromJS({ zalo: {} });
47
+ const expected = fromJS({});
48
+ const result = selectZaloDomain(state);
49
+ // Assert
50
+ expect(result).toEqual(expected);
51
+ });
52
+ });