@eohjsc/react-native-smart-city 0.2.97 → 0.3.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 (197) hide show
  1. package/README.md +35 -14
  2. package/package.json +4 -2
  3. package/src/commons/Action/ItemQuickAction.js +5 -2
  4. package/src/commons/ActionGroup/ColorPickerTemplate.js +1 -1
  5. package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
  6. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +12 -4
  7. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
  8. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +7 -4
  9. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
  10. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
  11. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
  12. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
  13. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
  14. package/src/commons/ActionGroup/OnOffTemplate/index.js +18 -15
  15. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -3
  16. package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -1
  17. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +4 -1
  18. package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +13 -9
  21. package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
  22. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
  23. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
  24. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
  25. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
  26. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
  27. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
  28. package/src/commons/ActionGroup/__test__/index.test.js +135 -0
  29. package/src/commons/Auth/AccountList.js +1 -1
  30. package/src/commons/Automate/ItemAutomate.js +1 -3
  31. package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
  32. package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
  33. package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
  34. package/src/commons/ConnectingProcess/index.js +1 -1
  35. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
  36. package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
  37. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
  38. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
  39. package/src/commons/Device/HistoryChart.js +4 -0
  40. package/src/commons/Device/LinearChart.js +15 -0
  41. package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
  42. package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
  43. package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
  44. package/src/commons/Explore/__test__/CityItem.test.js +33 -54
  45. package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
  46. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
  47. package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
  48. package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
  49. package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
  50. package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
  51. package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
  52. package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
  53. package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
  54. package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
  55. package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
  56. package/src/commons/FullLoading/index.js +2 -1
  57. package/src/commons/MenuActionAddnew/index.js +1 -0
  58. package/src/commons/MenuActionList/index.js +1 -0
  59. package/src/commons/MenuActionMore/index.js +1 -1
  60. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
  61. package/src/commons/PreventAccess/index.js +9 -1
  62. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
  63. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
  64. package/src/commons/SubUnit/OneTap/index.js +1 -2
  65. package/src/commons/Unit/SharedUnit.js +1 -0
  66. package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
  67. package/src/commons/WheelDateTimePicker/index.js +2 -1
  68. package/src/configs/API.js +87 -138
  69. package/src/configs/Constants.js +27 -1
  70. package/src/configs/SCConfig.js +2 -0
  71. package/src/iot/RemoteControl/__test__/GoogleHome.test.js +8 -30
  72. package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
  73. package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
  74. package/src/navigations/UnitStack.js +8 -0
  75. package/src/screens/AQIGuide/index.js +1 -1
  76. package/src/screens/ActivityLog/FilterPopup.js +2 -0
  77. package/src/screens/ActivityLog/__test__/index.test.js +38 -23
  78. package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
  79. package/src/screens/ActivityLog/index.js +2 -2
  80. package/src/screens/AddCommon/SelectSubUnit.js +1 -0
  81. package/src/screens/AddCommon/SelectUnit.js +1 -0
  82. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
  83. package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
  84. package/src/screens/AddLocationMaps/index.js +4 -1
  85. package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
  86. package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
  87. package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
  88. package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
  89. package/src/screens/AddNewAutoSmart/index.js +5 -2
  90. package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
  91. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
  92. package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
  93. package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
  94. package/src/screens/AddNewDevice/index.js +1 -0
  95. package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -1
  96. package/src/screens/AddNewGateway/SelectGateway.js +1 -0
  97. package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
  98. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
  99. package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
  100. package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
  101. package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
  102. package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
  103. package/src/screens/AddNewGateway/index.js +1 -0
  104. package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
  105. package/src/screens/AddNewOneTap/index.js +3 -2
  106. package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
  107. package/src/screens/Automate/__test__/index.test.js +7 -12
  108. package/src/screens/Automate/index.js +2 -0
  109. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
  110. package/src/screens/ConfirmUnitDeletion/index.js +7 -1
  111. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
  112. package/src/screens/Device/__test__/detail.test.js +23 -84
  113. package/src/screens/Device/detail.js +31 -8
  114. package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
  115. package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
  116. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
  117. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
  118. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
  119. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
  120. package/src/screens/EmergencySetting/index.js +4 -1
  121. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
  122. package/src/screens/Explore/index.js +2 -0
  123. package/src/screens/GuestInfo/__test__/index.test.js +14 -41
  124. package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
  125. package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
  126. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
  127. package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
  128. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
  129. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
  130. package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
  131. package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
  132. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
  133. package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
  134. package/src/screens/ManageAccess/index.js +2 -1
  135. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
  136. package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
  137. package/src/screens/Notification/__test__/Notification.test.js +14 -25
  138. package/src/screens/Notification/__test__/NotificationItem.test.js +4 -3
  139. package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
  140. package/src/screens/PlayBackCamera/index.js +19 -3
  141. package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
  142. package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
  143. package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
  144. package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
  145. package/src/screens/ScriptDetail/index.js +5 -4
  146. package/src/screens/SelectUnit/__test__/index.test.js +12 -55
  147. package/src/screens/SelectUnit/index.js +5 -2
  148. package/src/screens/SetSchedule/index.js +6 -2
  149. package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
  150. package/src/screens/SharedUnit/index.js +2 -0
  151. package/src/screens/Sharing/InfoMemberUnit.js +1 -1
  152. package/src/screens/Sharing/MemberList.js +12 -11
  153. package/src/screens/Sharing/SelectPermission.js +107 -70
  154. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
  155. package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
  156. package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
  157. package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
  158. package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
  159. package/src/screens/Sharing/hooks/index.js +3 -0
  160. package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
  161. package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
  162. package/src/screens/SideMenuDetail/index.js +149 -0
  163. package/src/screens/SmartIr/components/SelectBrand.js +1 -1
  164. package/src/screens/SubUnit/ManageSubUnit.js +1 -0
  165. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
  166. package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
  167. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
  168. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +47 -44
  169. package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
  170. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
  171. package/src/screens/TDSGuide/index.js +4 -1
  172. package/src/screens/UVIndexGuide/index.js +1 -1
  173. package/src/screens/Unit/ChooseLocation.js +1 -1
  174. package/src/screens/Unit/ManageUnit.js +1 -0
  175. package/src/screens/Unit/SelectAddress.js +4 -1
  176. package/src/screens/Unit/Station/index.js +1 -0
  177. package/src/screens/Unit/Summaries.js +1 -1
  178. package/src/screens/Unit/__test__/CheckSendEmail.test.js +15 -28
  179. package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
  180. package/src/screens/Unit/__test__/Detail.test.js +83 -185
  181. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
  182. package/src/screens/Unit/__test__/SelectAddress.test.js +13 -39
  183. package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
  184. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
  185. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
  186. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
  187. package/src/screens/Unit/components/SharedUnit/index.js +1 -0
  188. package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
  189. package/src/screens/UnitSummary/__test__/index.test.js +38 -31
  190. package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
  191. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
  192. package/src/screens/WaterQualityGuide/index.js +1 -1
  193. package/src/utils/Apis/axios.js +37 -13
  194. package/src/utils/I18n/translations/en.json +1 -0
  195. package/src/utils/I18n/translations/vi.json +1 -0
  196. package/src/utils/Route/index.js +1 -0
  197. package/src/utils/Utils.js +6 -6
@@ -1,13 +1,18 @@
1
- import axios from 'axios';
2
1
  import React from 'react';
3
2
  import { TouchableOpacity } from 'react-native';
4
3
  import Toast from 'react-native-toast-message';
5
4
  import { act, create } from 'react-test-renderer';
5
+ import MockAdapter from 'axios-mock-adapter';
6
+
6
7
  import SubUnitAutomate from '..';
7
8
  import { AUTOMATE_TYPE, TESTID } from '../../../../configs/Constants';
8
9
  import { SCProvider } from '../../../../context';
9
10
  import { mockSCStore } from '../../../../context/mockStore';
10
11
  import Routes from '../../../../utils/Route';
12
+ import api from '../../../../utils/Apis/axios';
13
+ import { API } from '../../../../configs';
14
+
15
+ const mock = new MockAdapter(api.axiosInstance);
11
16
 
12
17
  const wrapComponent = (data) => (
13
18
  <SCProvider initState={mockSCStore({})}>
@@ -32,8 +37,6 @@ jest.mock('@react-navigation/native', () => {
32
37
  };
33
38
  });
34
39
 
35
- jest.mock('axios');
36
-
37
40
  let tree;
38
41
  let data = {
39
42
  isOwner: true,
@@ -60,18 +63,9 @@ let data = {
60
63
 
61
64
  describe('test Item', () => {
62
65
  beforeEach(() => {
63
- axios.post.mockClear();
64
66
  mockedNavigate.mockClear();
65
67
  });
66
68
  test('render SubUnitAutomate isOwner and handleOnAddNew', async () => {
67
- const response = {
68
- status: 200,
69
- };
70
-
71
- axios.post.mockImplementation(async () => {
72
- return response;
73
- });
74
-
75
69
  await act(async () => {
76
70
  tree = await create(wrapComponent(data));
77
71
  });
@@ -114,6 +108,7 @@ describe('test Item', () => {
114
108
  el.type === TouchableOpacity
115
109
  );
116
110
  expect(handleScriptAction).toHaveLength(1);
111
+ mock.onPost(API.AUTOMATE.ACTION_ONE_TAP(1)).reply(200);
117
112
  await act(async () => {
118
113
  await handleScriptAction[0].props.onPress();
119
114
  });
@@ -127,14 +122,6 @@ describe('test Item', () => {
127
122
 
128
123
  test('render SubUnitAutomate not is owner handleScriptAction fail', async () => {
129
124
  data.isOwner = false;
130
- const response = {
131
- status: 400,
132
- };
133
-
134
- axios.post.mockImplementation(async () => {
135
- return response;
136
- });
137
-
138
125
  await act(async () => {
139
126
  tree = await create(wrapComponent(data));
140
127
  });
@@ -145,6 +132,7 @@ describe('test Item', () => {
145
132
  el.type === TouchableOpacity
146
133
  );
147
134
  expect(handleScriptAction).toHaveLength(1);
135
+ mock.onPost(API.AUTOMATE.ACTION_ONE_TAP(1)).reply(400);
148
136
  await act(async () => {
149
137
  await handleScriptAction[0].props.onPress();
150
138
  });
@@ -181,14 +169,6 @@ describe('test Item', () => {
181
169
  ],
182
170
  },
183
171
  ];
184
- const response = {
185
- status: 200,
186
- };
187
-
188
- axios.post.mockImplementation(async () => {
189
- return response;
190
- });
191
-
192
172
  await act(async () => {
193
173
  tree = await create(wrapComponent(data));
194
174
  });
@@ -233,13 +213,6 @@ describe('test Item', () => {
233
213
  ],
234
214
  },
235
215
  ];
236
- const response = {
237
- status: 200,
238
- };
239
-
240
- await axios.post.mockImplementation(async () => {
241
- return response;
242
- });
243
216
 
244
217
  await act(async () => {
245
218
  tree = await create(wrapComponent(data));
@@ -41,10 +41,9 @@ const SubUnitAutomate = ({ isOwner, listAutomate, unit, wrapItemStyle }) => {
41
41
  setAutomates(listAutomate[indexAutomate]);
42
42
  // eslint-disable-next-line react-hooks/exhaustive-deps
43
43
  }, [listAutomate]);
44
-
45
44
  return (
46
45
  <Section style={styles.noShadow}>
47
- <View style={styles.boxScenario}>
46
+ <View style={styles.boxScenario} testID={TESTID.VIEW_SUB_UNIT_AUTOMATE}>
48
47
  {listAutomate.map((item, index) => (
49
48
  <TouchableOpacity
50
49
  style={
@@ -39,6 +39,7 @@ const SharedUnit = ({
39
39
  }, [renewItem, index, unit, item]);
40
40
  const addPinSharedUnit = useCallback(async () => {
41
41
  const { success } = await axiosPost(API.UNIT.PIN_UNIT(unit.id));
42
+
42
43
  if (success) {
43
44
  item.is_pin = true;
44
45
  renewItem(index);
@@ -1,8 +1,8 @@
1
- import axios from 'axios';
2
1
  import React from 'react';
3
2
  import { create, act } from 'react-test-renderer';
4
3
  import moment from 'moment';
5
4
  import { useNavigation } from '@react-navigation/native';
5
+ import MockAdapter from 'axios-mock-adapter';
6
6
 
7
7
  import SharedUnit from '../SharedUnit';
8
8
  import { TESTID } from '../../../configs/Constants';
@@ -10,8 +10,9 @@ import { API } from '../../../configs';
10
10
  import Routes from '../../../utils/Route';
11
11
  import { SCProvider } from '../../../context';
12
12
  import { mockSCStore } from '../../../context/mockStore';
13
+ import api from '../../../utils/Apis/axios';
13
14
 
14
- jest.mock('axios');
15
+ const mock = new MockAdapter(api.axiosInstance);
15
16
 
16
17
  const mockNavigate = jest.fn();
17
18
  jest.mock('@react-navigation/native', () => {
@@ -38,8 +39,6 @@ describe('Test SharedUnit', () => {
38
39
  let tree, item, unit;
39
40
 
40
41
  beforeEach(() => {
41
- axios.post.mockClear();
42
-
43
42
  unit = {
44
43
  background: '',
45
44
  icon: '',
@@ -61,6 +60,12 @@ describe('Test SharedUnit', () => {
61
60
 
62
61
  test('test create SharedUnit unit is not pin, not star', async () => {
63
62
  const navigation = useNavigation();
63
+ const mockedRenewItem = jest.fn();
64
+ await act(async () => {
65
+ tree = await create(
66
+ wrapComponent(item, navigation, true, mockedRenewItem)
67
+ );
68
+ });
64
69
 
65
70
  await act(async () => {
66
71
  tree = await create(wrapComponent(item, navigation));
@@ -72,34 +77,39 @@ describe('Test SharedUnit', () => {
72
77
  act(() => {
73
78
  touchSharedUnit.props.onPress();
74
79
  });
75
- expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
76
- screen: Routes.UnitDetail,
77
- params: {
78
- unitId: 3,
79
- unitData: unit,
80
- },
81
- });
82
-
83
80
  const iconRemovePinSharedUnit = instance.findAll(
84
81
  (el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
85
82
  );
86
- expect(iconRemovePinSharedUnit).toHaveLength(0);
87
-
88
83
  const iconAddPinSharedUnit = instance.find(
89
84
  (el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
90
85
  );
86
+ mock.onPost(API.UNIT.PIN_UNIT(3)).reply(200);
87
+ act(() => {
88
+ iconAddPinSharedUnit.props.onPress();
89
+ });
90
+ mock.onPost(API.UNIT.PIN_UNIT(3)).reply(400);
91
91
  act(() => {
92
92
  iconAddPinSharedUnit.props.onPress();
93
93
  });
94
- expect(axios.post).toHaveBeenCalledWith(API.UNIT.PIN_UNIT(3));
95
-
96
94
  const iconAddStarSharedUnit = instance.find(
97
95
  (el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
98
96
  );
97
+ mock.onPost(API.UNIT.STAR_UNIT(3)).reply(200);
99
98
  act(() => {
100
99
  iconAddStarSharedUnit.props.onPress();
101
100
  });
102
- expect(axios.post).toHaveBeenCalledWith(API.UNIT.STAR_UNIT(3));
101
+ mock.onPost(API.UNIT.STAR_UNIT(3)).reply(400);
102
+ act(() => {
103
+ iconAddStarSharedUnit.props.onPress();
104
+ });
105
+ expect(iconRemovePinSharedUnit).toHaveLength(0);
106
+ expect(mockNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
107
+ screen: Routes.UnitDetail,
108
+ params: {
109
+ unitId: 3,
110
+ unitData: unit,
111
+ },
112
+ });
103
113
  });
104
114
 
105
115
  test('test create SharedUnit unit without unit owner', async () => {
@@ -148,183 +158,28 @@ describe('Test SharedUnit', () => {
148
158
  const iconRemovePinSharedUnit = instance.find(
149
159
  (el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
150
160
  );
161
+ mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(200);
162
+ act(() => {
163
+ iconRemovePinSharedUnit.props.onPress();
164
+ });
165
+ mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(400);
151
166
  act(() => {
152
167
  iconRemovePinSharedUnit.props.onPress();
153
168
  });
154
- expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNPIN_UNIT(3));
155
-
156
169
  const iconRemoveStarSharedUnit = instance.find(
157
170
  (el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
158
171
  );
172
+ mock.onPost(API.UNIT.UNSTAR_UNIT(3)).reply(200);
159
173
  act(() => {
160
174
  iconRemoveStarSharedUnit.props.onPress();
161
175
  });
162
- expect(axios.post).toHaveBeenCalledWith(API.UNIT.UNSTAR_UNIT(3));
163
- });
164
-
165
- test('test pin SharedUnit success', async () => {
166
- const navigation = useNavigation();
167
- const mockedRenewItem = jest.fn();
168
- await act(async () => {
169
- tree = await create(
170
- wrapComponent(item, navigation, true, mockedRenewItem)
171
- );
172
- });
173
- const instance = tree.root;
174
-
175
- const response = {
176
- success: true,
177
- status: 200,
178
- };
179
-
180
- jest.spyOn(axios, 'post').mockImplementation(() => {
181
- return response;
182
- });
183
-
184
- const iconAddPinSharedUnit = instance.find(
185
- (el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
186
- );
187
-
188
- const iconStarUnit = instance.find(
189
- (el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
190
- );
191
-
192
- await act(async () => {
193
- await iconAddPinSharedUnit.props.onPress();
194
- await iconStarUnit.props.onPress();
195
- });
196
-
197
- expect(mockedRenewItem).toHaveBeenCalledTimes(2);
198
- });
199
-
200
- test('test pin SharedUnit unsuccess', async () => {
201
- const navigation = useNavigation();
202
- const mockedRenewItem = jest.fn();
203
- await act(async () => {
204
- tree = await create(
205
- wrapComponent(item, navigation, true, mockedRenewItem)
206
- );
207
- });
208
- const instance = tree.root;
209
-
210
- const response = {
211
- success: false,
212
- status: 500,
213
- };
214
-
215
- jest.spyOn(axios, 'post').mockImplementation(() => {
216
- return response;
217
- });
218
-
219
- const iconAddPinSharedUnit = instance.find(
220
- (el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
221
- );
222
-
223
- const iconStarUnit = instance.find(
224
- (el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
225
- );
226
-
227
- await act(async () => {
228
- await iconAddPinSharedUnit.props.onPress();
229
- await iconStarUnit.props.onPress();
230
- });
231
-
232
- const iconRemovePinSharedUnit = instance.findAll(
233
- (el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
234
- );
235
-
236
- const iconRemoveStartUnit = instance.findAll(
237
- (el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
238
- );
239
-
240
- expect(mockedRenewItem).toHaveBeenCalledTimes(0);
241
- expect(iconRemovePinSharedUnit).toHaveLength(0);
242
- expect(iconRemoveStartUnit).toHaveLength(0);
243
- });
244
-
245
- test('test unpin SharedUnit success', async () => {
246
- const navigation = useNavigation();
247
- item.is_pin = true;
248
- item.is_star = true;
249
- const mockedRenewItem = jest.fn();
250
-
251
- await act(async () => {
252
- tree = await create(
253
- wrapComponent(item, navigation, true, mockedRenewItem)
254
- );
255
- });
256
- const instance = tree.root;
257
-
258
- const response = {
259
- success: true,
260
- status: 200,
261
- };
262
-
263
- jest.spyOn(axios, 'post').mockImplementation(() => {
264
- return response;
265
- });
266
-
267
- const iconRemovePinSharedUnit = instance.find(
268
- (el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
269
- );
270
-
271
- const iconRemoveStartUnit = instance.find(
272
- (el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
273
- );
274
-
275
- await act(async () => {
276
- await iconRemovePinSharedUnit.props.onPress();
277
- await iconRemoveStartUnit.props.onPress();
278
- });
279
-
280
- expect(mockedRenewItem).toHaveBeenCalledTimes(2);
281
- });
282
-
283
- test('test unpin SharedUnit unsuccess', async () => {
284
- const navigation = useNavigation();
285
- item.is_pin = true;
286
- item.is_star = true;
287
- const mockedRenewItem = jest.fn();
288
-
289
- await act(async () => {
290
- tree = await create(
291
- wrapComponent(item, navigation, true, mockedRenewItem)
292
- );
293
- });
294
- const instance = tree.root;
295
-
296
- const response = {
297
- success: false,
298
- status: 500,
299
- };
300
-
301
- jest.spyOn(axios, 'post').mockImplementation(() => {
302
- return response;
176
+ mock.onPost(API.UNIT.UNSTAR_UNIT(3)).reply(400);
177
+ act(() => {
178
+ iconRemoveStarSharedUnit.props.onPress();
303
179
  });
304
-
305
- const iconRemovePinSharedUnit = instance.find(
306
- (el) => el.props.testID === TESTID.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
307
- );
308
-
309
- const iconRemoveStartUnit = instance.find(
180
+ const iconRemoveStar = instance.findAll(
310
181
  (el) => el.props.testID === TESTID.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
311
182
  );
312
-
313
- await act(async () => {
314
- await iconRemovePinSharedUnit.props.onPress();
315
- await iconRemoveStartUnit.props.onPress();
316
- });
317
-
318
- const iconAddPinSharedUnit = instance.findAll(
319
- (el) => el.props.testID === TESTID.ICON_ADD_PIN_SHARED_UNIT + '-69'
320
- );
321
-
322
- const iconStarUnit = instance.findAll(
323
- (el) => el.props.testID === TESTID.ICON_ADD_STAR_SHARED_UNIT + '-69'
324
- );
325
-
326
- expect(mockedRenewItem).toHaveBeenCalledTimes(0);
327
- expect(iconAddPinSharedUnit).toHaveLength(0);
328
- expect(iconStarUnit).toHaveLength(0);
183
+ expect(iconRemoveStar).toHaveLength(3);
329
184
  });
330
185
  });
@@ -104,6 +104,7 @@ const WheelDateTimePicker = ({
104
104
 
105
105
  return (
106
106
  <BottomSheet
107
+ testID={TESTID.WHEEL_DATE_TIME_PICKER}
107
108
  isVisible={isVisible}
108
109
  onBackdropPress={onPickerCancel}
109
110
  onHide={onHide}
@@ -173,7 +174,7 @@ const WheelDateTimePicker = ({
173
174
  onLeftClick={onPickerCancel}
174
175
  rightTitle={t('done')}
175
176
  onRightClick={onDone}
176
- testIDPrefix={TESTID.WHEEL_DATE_TIME_PICKER}
177
+ testIDPrefix={TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}
177
178
  />
178
179
  </BottomSheet>
179
180
  );