@capillarytech/creatives-library 7.17.21-alpha.2 → 7.17.21

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,82 +0,0 @@
1
- import { expectSaga } from "redux-saga-test-plan";
2
- import { take, cancel, takeLatest } from "redux-saga/effects";
3
- import * as matchers from "redux-saga-test-plan/matchers";
4
- import { LOCATION_CHANGE } from "react-router-redux";
5
- import { throwError } from "redux-saga-test-plan/providers";
6
- import { createMockTask } from "redux-saga/utils";
7
- import * as types from "../constants";
8
- import { watchAiSuggestions, getAiSuggestions } from "../sagas";
9
- import * as Api from "../../../../services/api";
10
-
11
- describe("getAiSuggestions saga", () => {
12
- it("Should handle valid response from api", () => {
13
- const successCallback = () => {};
14
- const failureCallback = () => {};
15
- const action = {
16
- type: types.GET_AI_SUGGESTIONS,
17
- prompt: {},
18
- successCallback,
19
- failureCallback,
20
- };
21
- expectSaga(getAiSuggestions, action)
22
- .provide([
23
- [
24
- matchers.call.fn(Api.getAiSuggestions),
25
- {
26
- success: true,
27
- status: {
28
- isError: false,
29
- code: 200,
30
- message: "success",
31
- },
32
- message: "Meta data fetched successfully",
33
- response: {
34
- "https://response.com": 1400,
35
- },
36
- },
37
- ],
38
- [matchers.call.fn(successCallback)],
39
- ])
40
- .run();
41
- });
42
-
43
- it("Should handles error thrown from api", () => {
44
- const successCallback = () => {};
45
- const failureCallback = () => {};
46
- const action = {
47
- type: types.GET_AI_SUGGESTIONS,
48
- prompt: {},
49
- successCallback,
50
- failureCallback,
51
- };
52
- expectSaga(getAiSuggestions, action)
53
- .provide([[matchers.call.fn(Api.getAiSuggestions), throwError()]])
54
- .run();
55
- });
56
- });
57
-
58
- describe("watchAiSuggestions saga", () => {
59
- let generator = null;
60
- beforeEach(() => {
61
- generator = watchAiSuggestions();
62
- });
63
- it("Should handle valid response from api", () => {
64
- const progress1 = generator.next();
65
- const mockTask = takeLatest(types.GET_AI_SUGGESTIONS, getAiSuggestions);
66
- expect(progress1.value).toEqual(mockTask);
67
- const progress2 = generator.next();
68
- expect(progress2.value).toEqual(take(LOCATION_CHANGE));
69
- });
70
-
71
- it("Should handle LOCATION_CHANGE action and cancel the watcher", () => {
72
- generator = watchAiSuggestions();
73
- const mockTask = createMockTask();
74
-
75
- expect(generator.next().value).toEqual(
76
- takeLatest(types.GET_AI_SUGGESTIONS, getAiSuggestions)
77
- );
78
- expect(generator.next(mockTask).value).toEqual(take(LOCATION_CHANGE));
79
- expect(generator.next().value).toEqual(cancel(mockTask));
80
- expect(generator.next().done).toEqual(true);
81
- });
82
- });
@@ -1,41 +0,0 @@
1
- import React from 'react';
2
- import "@testing-library/jest-dom";
3
- import configureStore from "../../../store";
4
- import { injectIntl } from "react-intl";
5
- import { fireEvent } from "@testing-library/react";
6
- import { TagList } from '../index';
7
- import { TagListData } from './mockdata';
8
- import { Provider } from 'react-redux';
9
- import { screen, render } from '../../../utils/test-utils';
10
-
11
-
12
- const initializeTagList = (props) => {
13
- const store = configureStore({}, null);
14
- const Component = injectIntl(TagList);
15
-
16
- const propsObj = {
17
- ...TagListData,
18
- onTagSelect: jest.fn(),
19
- ...props,
20
- };
21
-
22
- return render(
23
- <Provider store={store}>
24
- <Component {...propsObj} />
25
- </Provider>
26
- );
27
- };
28
-
29
-
30
- describe("TagList test : UNIT", () => {
31
- it("should render the TagList component with default props amd addLabel Button", async () => {
32
- initializeTagList();
33
-
34
- const addLabelButton = screen.getByRole('button', {
35
- name: /add label/i
36
- })
37
- expect(addLabelButton).toBeInTheDocument();
38
-
39
- fireEvent.click(addLabelButton);
40
- });
41
- });
@@ -1,108 +0,0 @@
1
- export const TagListData = {
2
- tags : [
3
- {
4
- "_id": "5a291cdd85c3db29a2041e5a",
5
- "type": "TAG",
6
- "definition": {
7
- "label": {
8
- "en": "Optout",
9
- "ja-JP": "撤回"
10
- },
11
- "value": "optout",
12
- "subtags": [],
13
- "tag-header": false,
14
- "supportedModules": [
15
- {
16
- "context": "journey",
17
- "layout": "sms",
18
- "mandatory": false
19
- },
20
- {
21
- "context": "outbound",
22
- "layout": "sms",
23
- "mandatory": false
24
- },
25
- {
26
- "context": "default",
27
- "layout": "sms",
28
- "mandatory": false
29
- },
30
- {
31
- "context": "coupon_expiry",
32
- "layout": "sms",
33
- "mandatory": false
34
- },
35
- {
36
- "context": "coupons",
37
- "layout": "sms",
38
- "mandatory": false
39
- }
40
- ]
41
- },
42
- "scope": {
43
- "tag": "STANDARD",
44
- "orgId": -1,
45
- "verticals": []
46
- },
47
- "isActive": true,
48
- "createdBy": 4,
49
- "updatedBy": 15000449,
50
- "createdAt": "2017-12-07T10:50:05.800Z",
51
- "updatedAt": "2018-01-22T11:43:05.611Z"
52
- },
53
- ],
54
- injectedTags : {
55
- "dummys": {
56
- "name": "dummys",
57
- "subtags": {
58
- "custom_field.age_group": {
59
- "name": "age_group",
60
- "desc": "age_group"
61
- },
62
- },
63
- "tag-header": true
64
- },
65
- "Registration custom fields": {
66
- "name": "Registration custom fields",
67
- "subtags": {
68
- "custom_field.age_group": {
69
- "name": "age_group",
70
- "desc": "age_group"
71
- },
72
- },
73
- "tag-header": true
74
- },
75
- "Customer extended fields": {
76
- "name": "Customer extended fields",
77
- "subtags": {
78
- "extended_field.gender": {
79
- "name": "gender",
80
- "desc": "Gender"
81
- },
82
- "extended_field.marital_status": {
83
- "name": "marital_status",
84
- "desc": "Marital Status",
85
- },
86
- },
87
- "tag-header": true
88
- }
89
- },
90
- "authData": {},
91
- "moduleFilterEnabled": true,
92
- "label": "Add label",
93
- "location": {
94
- "pathname": "/sms/edit",
95
- "query": {
96
- "type": false,
97
- "module": "default"
98
- },
99
- "search": ""
100
- },
101
- "className": "add-label",
102
- "id": "tagList",
103
- "userLocale": "en",
104
- "TagList": {},
105
- "actions": {},
106
- "globalActions": {},
107
- "isNewVersionFlow": false,
108
- }