@capillarytech/creatives-library 8.0.48-alpha.0 → 8.0.48

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 {
7
7
  import {
8
8
  authorize, loginFlow, logoutFlow, watchForLogoutFlow, capSaga,
9
9
  fetchSchemaForEntity,
10
+ fetchUserInfo,
10
11
  } from '../sagas';
11
12
  import * as api from '../../../services/api';
12
13
  import {
@@ -17,10 +18,76 @@ import {
17
18
  LOGOUT_FAILURE,
18
19
  GET_SCHEMA_FOR_ENTITY_SUCCESS,
19
20
  GET_SCHEMA_FOR_ENTITY_FAILURE,
21
+ GET_USER_DATA_SUCCESS,
22
+ GET_USER_DATA_FAILURE,
20
23
  } from '../constants';
21
24
 
22
25
  const error = new Error('error');
23
26
 
27
+ describe('fetchUserInfo Saga', () => {
28
+ it('should handle success scenario', () => {
29
+ const mockCallback = jest.fn();
30
+ const mockApiResponse = {
31
+ user: { id: 1, name: 'Test User' },
32
+ currentOrgDetails: {
33
+ basic_details: {
34
+ base_language: '',
35
+ supported_languages: [],
36
+ },
37
+ },
38
+ currentOrgId: '123',
39
+ };
40
+
41
+ const expectedUserData = { id: 1, name: 'Test User' };
42
+ const updatedOrgDetails = {
43
+ basic_details: {
44
+ base_language: 'en',
45
+ supported_languages: [
46
+ {
47
+ lang_id: 69,
48
+ language: 'English',
49
+ iso_code: 'en',
50
+ },
51
+ ],
52
+ },
53
+ };
54
+
55
+ return expectSaga(fetchUserInfo, { callback: mockCallback })
56
+ .provide([
57
+ [matchers.call.fn(api.getUserData), mockApiResponse],
58
+ ])
59
+ .call(api.getUserData)
60
+ .put({
61
+ type: GET_USER_DATA_SUCCESS,
62
+ userData: expectedUserData,
63
+ currentOrgId: '123',
64
+ currentOrgDetails: {
65
+ ...mockApiResponse.currentOrgDetails,
66
+ basic_details: {
67
+ ...updatedOrgDetails.basic_details,
68
+ },
69
+ },
70
+ })
71
+ .run();
72
+ });
73
+
74
+ it('should handle failure scenario', () => {
75
+ const mockCallback = jest.fn();
76
+ const mockError = new Error('Some error');
77
+
78
+ return expectSaga(fetchUserInfo, { callback: mockCallback })
79
+ .provide([
80
+ [matchers.call.fn(api.getUserData), throwError(mockError)],
81
+ ])
82
+ .call(api.getUserData)
83
+ .put({
84
+ type: GET_USER_DATA_FAILURE,
85
+ error: mockError,
86
+ })
87
+ .run();
88
+ });
89
+ });
90
+
24
91
  describe('capSaga', () => {
25
92
  it("should initialize all capSaga-related watcher sagas without error", () => {
26
93
  return expectSaga(capSaga).run();
@@ -213,4 +280,5 @@ describe("fetchSchemaForEntity", () => {
213
280
  })
214
281
  .run();
215
282
  });
216
- });
283
+ });
284
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.48-alpha.0",
4
+ "version": "8.0.48",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",