@eohjsc/react-native-smart-city 0.3.71 → 0.3.72

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 (151) hide show
  1. package/index.js +0 -2
  2. package/package.json +4 -5
  3. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
  4. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
  5. package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLockStyle.js +1 -1
  6. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +12 -11
  7. package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -3
  8. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +1 -0
  9. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -0
  10. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +39 -34
  11. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +1 -1
  12. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +19 -10
  13. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +0 -1
  14. package/src/commons/ActionGroup/__test__/index.test.js +24 -16
  15. package/src/commons/ActionTemplate/__test__/index.test.js +5 -1
  16. package/src/commons/AlertAction/__test__/AlertAction.test.js +2 -2
  17. package/src/commons/Automate/__test__/ItemAutomate.test.js +1 -1
  18. package/src/commons/Calendar/__test__/Calendar.test.js +3 -5
  19. package/src/commons/CameraDevice/index.js +37 -22
  20. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +3 -3
  21. package/src/commons/Dashboard/MyUnit/index.js +1 -1
  22. package/src/commons/Device/ConnectedViewHeader.js +2 -1
  23. package/src/commons/Device/DeviceAlertStatus.js +1 -1
  24. package/src/commons/Device/DisconnectedView.js +10 -14
  25. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +1 -1
  26. package/src/commons/Device/HorizontalBarChart.js +1 -1
  27. package/src/commons/Device/LinearChart/LinearChart.test.js +10 -4
  28. package/src/commons/Device/LinearChart.js +5 -1
  29. package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
  30. package/src/commons/Device/SonosSpeaker/index.js +1 -1
  31. package/src/commons/Device/WindDirection/Compass/Compass.test.js +12 -27
  32. package/src/commons/Device/WindDirection/Compass/index.js +15 -23
  33. package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +4 -4
  34. package/src/commons/Device/WindSpeed/__test__/ChartInfo.test.js +2 -2
  35. package/src/commons/Device/__test__/ConnectedViewHeader.test.js +11 -8
  36. package/src/commons/Device/__test__/DisconnectedView.test.js +8 -45
  37. package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +1 -1
  38. package/src/commons/DisplayChecking/index.js +4 -3
  39. package/src/commons/DisplayChecking/styles.js +2 -2
  40. package/src/commons/MediaPlayer/index.js +2 -1
  41. package/src/commons/MediaPlayerDetail/MediaPlayerFull.js +1 -1
  42. package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +0 -1
  43. package/src/commons/MediaPlayerDetail/index.js +2 -3
  44. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +2 -1
  45. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -1
  46. package/src/commons/MenuActionList/index.js +8 -70
  47. package/src/commons/MenuActionList/styles.js +68 -0
  48. package/src/commons/Modal/__test__/ModalBottom.test.js +1 -10
  49. package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +45 -31
  50. package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +15 -13
  51. package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +12 -9
  52. package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +19 -13
  53. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +5 -5
  54. package/src/commons/PreventAccess/index.js +3 -3
  55. package/src/commons/Sharing/__test__/MemberList.test.js +17 -6
  56. package/src/commons/Sharing/__test__/RowMember.test.js +0 -2
  57. package/src/commons/SubUnit/OneTap/index.js +6 -1
  58. package/src/commons/Today/__test__/Today.test.js +3 -3
  59. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +1 -1
  60. package/src/configs/IOPinConstants.js +285 -0
  61. package/src/libs/react-native-parallax-scroll-view/index.js +2 -1
  62. package/src/navigations/AllGatewayStack.js +3 -3
  63. package/src/navigations/UnitStack.js +0 -6
  64. package/src/screens/ActivityLog/__test__/index.test.js +16 -22
  65. package/src/screens/ActivityLog/index.js +2 -3
  66. package/src/screens/AddNewAction/SelectAction.js +3 -0
  67. package/src/screens/AddNewAction/SetupSensor.js +3 -3
  68. package/src/screens/AddNewAction/__test__/SelectAction.test.js +12 -0
  69. package/src/screens/AddNewAction/__test__/SetupSensor.test.js +11 -24
  70. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectRouterGuide.test.js +0 -1
  71. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +0 -1
  72. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +0 -1
  73. package/src/screens/AddNewGateway/SetupGatewayWifiStyles.js +2 -2
  74. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +22 -7
  75. package/src/screens/AllCamera/__test__/index.test.js +1 -1
  76. package/src/screens/AllCamera/index.js +1 -1
  77. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +82 -0
  78. package/src/screens/AllGateway/DetailConfigActionInternal/index.js +84 -5
  79. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +63 -57
  80. package/src/screens/AllGateway/DeviceInternalDetail/index.js +32 -32
  81. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +40 -79
  82. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -42
  83. package/src/screens/AllGateway/DeviceZigbeeDetail/index.js +4 -4
  84. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +49 -61
  85. package/src/screens/AllGateway/GatewayDetail/index.js +2 -1
  86. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
  87. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  88. package/src/screens/AllGateway/hooks/useGateway.js +1 -0
  89. package/src/screens/AllGateway/test-utils.js +20 -0
  90. package/src/screens/Device/__test__/detail.test.js +8 -3
  91. package/src/screens/Device/components/SensorDisplayItem.js +1 -5
  92. package/src/screens/EmergencyContacts/EmergencyContactsList.js +1 -4
  93. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +32 -4
  94. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -5
  95. package/src/screens/EmergencyContacts/__test__/hooks.test.js +1 -1
  96. package/src/screens/GuestInfo/__test__/index.test.js +26 -14
  97. package/src/screens/HanetCamera/CaptureFaceID.js +1 -1
  98. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +1 -5
  99. package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +1 -1
  100. package/src/screens/PlayBackCamera/Timer.js +2 -3
  101. package/src/screens/PlayBackCamera/__test__/index.test.js +69 -48
  102. package/src/screens/ScanChipQR/components/QRScan/index.js +8 -8
  103. package/src/screens/SharedUnit/__test__/ShareUnit.test.js +20 -10
  104. package/src/screens/SharedUnit/index.js +19 -17
  105. package/src/screens/SmartAccount/Connecting/index.js +2 -2
  106. package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +4 -2
  107. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +17 -8
  108. package/src/screens/SmartAccount/ListDevice/index.js +1 -1
  109. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +9 -6
  110. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +1 -0
  111. package/src/screens/SmartAccount/__test__/Connecting.test.js +2 -1
  112. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +17 -6
  113. package/src/screens/SubUnit/EditSubUnit.js +6 -6
  114. package/src/screens/SubUnit/EditSubUnitStyles.js +2 -2
  115. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -6
  116. package/src/screens/SubUnit/__test__/Detail.test.js +2 -3
  117. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +25 -10
  118. package/src/screens/Template/EditTemplate.js +13 -3
  119. package/src/screens/Template/__test__/EditTemplate.test.js +21 -15
  120. package/src/screens/Unit/Detail.js +157 -121
  121. package/src/screens/Unit/ManageUnit.js +3 -3
  122. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  123. package/src/screens/Unit/__test__/Detail.test.js +40 -20
  124. package/src/screens/Unit/__test__/ManageUnit.test.js +18 -15
  125. package/src/screens/Unit/components/AutomateScript/index.js +9 -8
  126. package/src/screens/Unit/components/Header/index.js +1 -14
  127. package/src/screens/Unit/components/__test__/AutomateScript.test.js +10 -36
  128. package/src/screens/Unit/components/__test__/Header.test.js +14 -9
  129. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +4 -5
  130. package/src/utils/Route/index.js +1 -2
  131. package/src/utils/Utils.js +62 -2
  132. package/src/commons/Explore/ActivityIndicator/index.js +0 -49
  133. package/src/commons/Explore/CityItem/index.js +0 -116
  134. package/src/commons/Explore/HeaderExplore/index.js +0 -44
  135. package/src/commons/Explore/HeaderLabel/index.js +0 -46
  136. package/src/commons/Explore/LocationItem/index.js +0 -71
  137. package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +0 -58
  138. package/src/commons/Explore/SearchBox/index.js +0 -59
  139. package/src/commons/Explore/__test__/CityItem.test.js +0 -156
  140. package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -25
  141. package/src/commons/Explore/__test__/HeaderLabel.test.js +0 -33
  142. package/src/commons/Explore/__test__/LocationItem.test.js +0 -31
  143. package/src/screens/Explore/__test__/Explore.test.js +0 -43
  144. package/src/screens/Explore/index.js +0 -201
  145. package/src/screens/Unit/MyAllUnit/index.js +0 -44
  146. package/src/screens/Unit/__test__/MyAllUnit.test.js +0 -87
  147. package/src/screens/Unit/components/ListMyAllUnit/index.js +0 -162
  148. package/src/screens/Unit/components/MyAllUnit/__test__/Header.test.js +0 -117
  149. package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
  150. package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
  151. package/src/screens/Unit/components/MyAllUnit/index.js +0 -44
package/index.js CHANGED
@@ -9,7 +9,6 @@ import { UnitStack } from './src/navigations/UnitStack';
9
9
  import { EmergencyContactsStack } from './src/navigations/EmergencyContactsStack';
10
10
  import { AddUnitStack } from './src/navigations/AddUnitStack';
11
11
  import SharedStack from './src/navigations/SharedStack';
12
- import Explore from './src/screens/Explore';
13
12
  import { AddLGDeviceStack } from './src/navigations/AddLGDeviceStack';
14
13
  import { initSCConfig } from './src/configs';
15
14
  import AutomateStack from './src/navigations/AutomateStack';
@@ -34,7 +33,6 @@ export {
34
33
  UnitStack,
35
34
  AddUnitStack,
36
35
  SharedStack,
37
- Explore,
38
36
  SCProvider,
39
37
  SCContext,
40
38
  AddLGDeviceStack,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eohjsc/react-native-smart-city",
3
3
  "title": "React Native Smart Home",
4
- "version": "0.3.71",
4
+ "version": "0.3.72",
5
5
  "description": "TODO",
6
6
  "main": "index.js",
7
7
  "files": [
@@ -119,7 +119,6 @@
119
119
  "@react-native-community/segmented-control": "^2.1.1",
120
120
  "@react-native-community/slider": "^3.0.3",
121
121
  "@react-native-community/toolbar-android": "^0.1.0-rc.2",
122
- "@react-native-community/viewpager": "^4.1.4",
123
122
  "@react-native-picker/picker": "^1.16.7",
124
123
  "@react-navigation/bottom-tabs": "^5.8.0",
125
124
  "@react-navigation/drawer": "^5.9.0",
@@ -129,6 +128,7 @@
129
128
  "@testing-library/react-hooks": "^6.0.0",
130
129
  "apisauce": "^2.1.5",
131
130
  "axios": "^0.19.2",
131
+ "deprecated-react-native-prop-types": "^2.3.0",
132
132
  "dotenv": "^8.2.0",
133
133
  "google-libphonenumber": "^3.2.10",
134
134
  "home-assistant-js-websocket": "^5.7.0",
@@ -153,7 +153,6 @@
153
153
  "react-native-android-keyboard-adjust": "^1.2.0",
154
154
  "react-native-android-location-enabler": "^1.2.2",
155
155
  "react-native-android-wifi": "^0.0.41",
156
- "react-native-animated-ellipsis": "^2.0.0",
157
156
  "react-native-appearance": "^0.3.4",
158
157
  "react-native-base64": "^0.1.0",
159
158
  "react-native-ble-plx": "^2.0.3",
@@ -174,11 +173,13 @@
174
173
  "react-native-input-credit-card": "^0.5.5",
175
174
  "react-native-iphone-x-helper": "^1.2.1",
176
175
  "react-native-linear-gradient": "^2.5.6",
176
+ "react-native-loading-dots": "^1.3.2",
177
177
  "react-native-localize": "^1.4.1",
178
178
  "react-native-maps": "0.27.1",
179
179
  "react-native-maps-directions": "^1.8.0",
180
180
  "react-native-modal": "^11.5.6",
181
181
  "react-native-modal-datetime-picker": "^8.9.3",
182
+ "react-native-new-snap-carousel": "^3.9.3",
182
183
  "react-native-onesignal": "^4.3.1",
183
184
  "react-native-pager-view": "^5.4.1",
184
185
  "react-native-parallax-scroll-view": "^0.21.3",
@@ -190,8 +191,6 @@
190
191
  "react-native-responsive-fontsize": "^0.5.1",
191
192
  "react-native-safe-area-context": "^3.1.1",
192
193
  "react-native-screens": "^2.9.0",
193
- "react-native-slider": "^0.11.0",
194
- "react-native-snap-carousel": "4.0.0-beta.5",
195
194
  "react-native-super-grid": "^4.0.3",
196
195
  "react-native-svg": "^12.1.0",
197
196
  "react-native-toast-message": "^2.1.1",
@@ -1,6 +1,6 @@
1
1
  import React, { memo, useCallback, useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import Slider from 'react-native-slider';
3
+ import Slider from '@react-native-community/slider';
4
4
  import Text from '../../../Text';
5
5
  import { HeaderCustom } from '../../../Header';
6
6
  import ButtonWrapper from './ButtonWrapper';
@@ -56,7 +56,7 @@ const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
56
56
  }, [config, configValues, configuration, is_on_value]);
57
57
 
58
58
  return (
59
- <>
59
+ <View style={styles.wrap}>
60
60
  <View>
61
61
  <TouchableOpacity
62
62
  onPress={handleActionSmartLock}
@@ -78,7 +78,7 @@ const OnOffSmartLock = memo(({ actionGroup = {}, doAction, sensor = {} }) => {
78
78
  {t(isUnlock ? 'door_is_open' : 'door_is_close')}
79
79
  </Text>
80
80
  </View>
81
- </>
81
+ </View>
82
82
  );
83
83
  });
84
84
 
@@ -6,7 +6,7 @@ export default StyleSheet.create({
6
6
  flex: 1,
7
7
  },
8
8
  wrap: {
9
- paddingHorizontal: 16,
9
+ padding: 16,
10
10
  },
11
11
  section: {
12
12
  borderRadius: 10,
@@ -5,6 +5,7 @@ import SetupGeneratePasscode from '../index';
5
5
  import { mockSCStore } from '../../../../../context/mockStore';
6
6
  import { AccessibilityLabel } from '../../../../../configs/Constants';
7
7
  import { SCProvider } from '../../../../../context';
8
+ import WheelDateTimePicker from '../../../../WheelDateTimePicker';
8
9
 
9
10
  const mockNavigate = jest.fn();
10
11
  jest.mock('@react-navigation/native', () => {
@@ -66,17 +67,17 @@ describe('Test SetupGeneratePasscode', () => {
66
67
  expect(changeTime[0]).toBeDefined();
67
68
  expect(changeDuration[0]).toBeDefined();
68
69
 
69
- await changeDuration[0].props.onPressSetMinute();
70
- await changeDuration[0].props.onPressSelectCircle();
71
- await changeTime[0].props.onPressSetTime();
70
+ await act(async () => {
71
+ await changeDuration[0].props.onPressSetMinute();
72
+ });
73
+ await act(async () => {
74
+ await changeDuration[0].props.onPressSelectCircle();
75
+ });
76
+ await act(async () => {
77
+ await changeTime[0].props.onPressSetTime();
78
+ });
72
79
 
73
- const wheelDateTimePicker = instance.findAll(
74
- (item) =>
75
- item.props.accessibilityLabel ===
76
- `${AccessibilityLabel.WHEEL_DATE_TIME_PICKER_BUTTON}${AccessibilityLabel.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
77
- );
78
- await wheelDateTimePicker[5].props.onClick();
79
- await wheelDateTimePicker[11].props.onClick();
80
- await wheelDateTimePicker[17].props.onClick();
80
+ const wheelDateTimePicker = instance.findAllByType(WheelDateTimePicker);
81
+ expect(wheelDateTimePicker).toHaveLength(3);
81
82
  });
82
83
  });
@@ -5,7 +5,7 @@ import styles from './SliderRangeTemplateStyles';
5
5
  import Text from '../Text';
6
6
  import { Colors } from '../../configs';
7
7
  import SvgBrightness from '../../../assets/images/brightness.svg';
8
- import SliderRange from 'react-native-slider';
8
+ import Slider from '@react-native-community/slider';
9
9
  import { useConfigGlobalState } from '../../iot/states';
10
10
  import { DEVICE_TYPE } from '../../configs/Constants';
11
11
 
@@ -75,7 +75,7 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
75
75
  </Text>
76
76
  </View>
77
77
  <View style={styles.RightBrightness}>
78
- <SliderRange
78
+ <Slider
79
79
  style={styles.slider}
80
80
  value={valueBrightness}
81
81
  onSlidingComplete={onChangeBrightness}
@@ -89,7 +89,6 @@ const SliderRangeTemplate = memo(({ actionGroup = {}, doAction, sensor }) => {
89
89
  trackStyle={styles.trackSlider}
90
90
  thumbStyle={styles.thumbSlider}
91
91
  />
92
-
93
92
  <View style={styles.valuePercent}>
94
93
  <Text type="Label" style={styles.textValuePercent}>
95
94
  {`${valueBrightness}%`}
@@ -189,6 +189,7 @@ const SmartTiviActionTemplate = memo(
189
189
  FakeDataChannel.map((item, index) => {
190
190
  return (
191
191
  <RectangleButton
192
+ key={index}
192
193
  type="row"
193
194
  onPress={onPressButton(
194
195
  SMART_TIVI_BUTTON.CHANNEL_BUTTON,
@@ -120,6 +120,7 @@ const TwoButtonTemplate = memo(
120
120
  accessibilityLabel={item.accessibilityLabel}
121
121
  style={styles.bigCircle}
122
122
  onPress={item.onPress}
123
+ key={index}
123
124
  >
124
125
  <View style={styles.smallCircle}>
125
126
  <Icon
@@ -85,6 +85,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
85
85
  wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
86
86
  });
87
87
  const instance = wrapper.root;
88
+ await act(async () => {
89
+ instance.findAllByType(TouchableOpacity)[0].props.onPress();
90
+ });
88
91
 
89
92
  const texts = instance.findAllByType(Text);
90
93
  const radioCircles = instance.findAllByType(RadioCircle);
@@ -104,6 +107,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
104
107
  wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
105
108
  });
106
109
  const instance = wrapper.root;
110
+ await act(async () => {
111
+ instance.findAllByType(TouchableOpacity)[0].props.onPress();
112
+ });
107
113
 
108
114
  const text = instance.findAllByType(Text);
109
115
  expect(text[0].props.children).toEqual('Fan Speed'); // title
@@ -118,12 +124,20 @@ describe('Test OptionsDropdownActionTemplate', () => {
118
124
  const instance = wrapper.root;
119
125
 
120
126
  const touchs = instance.findAllByType(TouchableOpacity);
121
- expect(touchs).toHaveLength(5); // 1 show popup + 2 alert bottom button + 2 option
122
127
  const showListOption = touchs[0];
123
128
 
124
129
  const texts = instance.findAllByType(Text);
125
130
  expect(texts[1].props.children).toEqual('Level2'); // selectedOption
126
131
 
132
+ const alertAction = instance.findByType(AlertAction);
133
+ expect(alertAction.props.visible).toBeFalsy();
134
+
135
+ // show option
136
+ await act(async () => {
137
+ await showListOption.props.onPress();
138
+ });
139
+ expect(alertAction.props.visible).toBeTruthy();
140
+
127
141
  const radioCircles = instance.findAllByType(RadioCircle);
128
142
  expect(radioCircles[0].props.active).toBeFalsy();
129
143
  expect(radioCircles[1].props.active).toBeTruthy(); // choosing 2nd radioCircle in list
@@ -136,15 +150,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
136
150
  );
137
151
  expect(listChoosingOption).toHaveLength(2); // 2 option
138
152
 
139
- const alertAction = instance.findByType(AlertAction);
140
- expect(alertAction.props.visible).toBeFalsy();
141
-
142
- // show option
143
- await act(async () => {
144
- await showListOption.props.onPress();
145
- });
146
- expect(alertAction.props.visible).toBeTruthy();
147
-
148
153
  // Choosed Level1 option
149
154
  await act(async () => {
150
155
  await listChoosingOption[0].props.onPress();
@@ -188,12 +193,20 @@ describe('Test OptionsDropdownActionTemplate', () => {
188
193
  const instance = wrapper.root;
189
194
 
190
195
  const touchs = instance.findAllByType(TouchableOpacity);
191
- expect(touchs).toHaveLength(5);
192
196
  const showListOption = touchs[0];
193
197
 
194
198
  const texts = instance.findAllByType(Text);
195
199
  expect(texts[1].props.children).toEqual('Level2');
196
200
 
201
+ const alertAction = instance.findByType(AlertAction);
202
+ expect(alertAction.props.visible).toBeFalsy();
203
+
204
+ // show option
205
+ await act(async () => {
206
+ await showListOption.props.onPress();
207
+ });
208
+ expect(alertAction.props.visible).toBeTruthy();
209
+
197
210
  const radioCircles = instance.findAllByType(RadioCircle);
198
211
  expect(radioCircles[0].props.active).toBeFalsy();
199
212
  expect(radioCircles[1].props.active).toBeTruthy();
@@ -206,15 +219,6 @@ describe('Test OptionsDropdownActionTemplate', () => {
206
219
  );
207
220
  expect(listChoosingOption).toHaveLength(2);
208
221
 
209
- const alertAction = instance.findByType(AlertAction);
210
- expect(alertAction.props.visible).toBeFalsy();
211
-
212
- // show option
213
- await act(async () => {
214
- await showListOption.props.onPress();
215
- });
216
- expect(alertAction.props.visible).toBeTruthy();
217
-
218
222
  // Choosed Level1 option
219
223
  await act(async () => {
220
224
  await listChoosingOption[0].props.onPress();
@@ -247,6 +251,9 @@ describe('Test OptionsDropdownActionTemplate', () => {
247
251
  wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
248
252
  });
249
253
  const instance = wrapper.root;
254
+ await act(async () => {
255
+ instance.findAllByType(TouchableOpacity)[0].props.onPress();
256
+ });
250
257
  const textDisplaySelected = instance.find(
251
258
  (el) =>
252
259
  el.props.accessibilityLabel ===
@@ -257,6 +264,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
257
264
  getTranslate('en', 'not_available')
258
265
  );
259
266
  });
267
+
260
268
  it('doAction sensor device type is GOOGLE_HOME', async () => {
261
269
  actionGroup.configuration.options[0].value_text = 'level-1';
262
270
  sensor.device_type = DEVICE_TYPE.GOOGLE_HOME;
@@ -265,26 +273,12 @@ describe('Test OptionsDropdownActionTemplate', () => {
265
273
  wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
266
274
  });
267
275
  const instance = wrapper.root;
268
-
269
276
  const touchs = instance.findAllByType(TouchableOpacity);
270
- expect(touchs).toHaveLength(5);
271
277
  const showListOption = touchs[0];
272
278
 
273
279
  const texts = instance.findAllByType(Text);
274
280
  expect(texts[1].props.children).toEqual('Level2');
275
281
 
276
- const radioCircles = instance.findAllByType(RadioCircle);
277
- expect(radioCircles[0].props.active).toBeFalsy();
278
- expect(radioCircles[1].props.active).toBeTruthy();
279
-
280
- const listChoosingOption = instance.findAll(
281
- (el) =>
282
- el.props.accessibilityLabel ===
283
- AccessibilityLabel.OPTIONS_DROPDOWN_ACTION_CHOOSING_ITEM &&
284
- el.type === TouchableOpacity
285
- );
286
- expect(listChoosingOption).toHaveLength(2);
287
-
288
282
  const alertAction = instance.findByType(AlertAction);
289
283
  expect(alertAction.props.visible).toBeFalsy();
290
284
 
@@ -294,6 +288,17 @@ describe('Test OptionsDropdownActionTemplate', () => {
294
288
  });
295
289
  expect(alertAction.props.visible).toBeTruthy();
296
290
 
291
+ const listChoosingOption = instance.findAll(
292
+ (el) =>
293
+ el.props.accessibilityLabel ===
294
+ AccessibilityLabel.OPTIONS_DROPDOWN_ACTION_CHOOSING_ITEM &&
295
+ el.type === TouchableOpacity
296
+ );
297
+ expect(listChoosingOption).toHaveLength(2);
298
+ const radioCircles = instance.findAllByType(RadioCircle);
299
+ expect(radioCircles[0].props.active).toBeFalsy();
300
+ expect(radioCircles[1].props.active).toBeTruthy();
301
+
297
302
  // Choose Level1 option
298
303
  await act(async () => {
299
304
  await listChoosingOption[0].props.onPress();
@@ -5,7 +5,7 @@ import SliderRangeTemplate from '../SliderRangeTemplate';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
7
  import { useConfigGlobalState } from '../../../iot/states';
8
- import SliderRange from 'react-native-slider';
8
+ import SliderRange from '@react-native-community/slider';
9
9
 
10
10
  jest.mock('../../../iot/Monitor');
11
11
  const mockDoAction = jest.fn();
@@ -74,7 +74,7 @@ describe('Test TimerActionTemplate success with config value', () => {
74
74
  });
75
75
  const instance = wrapper.root;
76
76
  const texts = instance.findAllByType(Text);
77
- expect(texts).toHaveLength(6);
77
+ expect(texts[0].props.children).toEqual(undefined);
78
78
  });
79
79
 
80
80
  it('render template', async () => {
@@ -84,19 +84,20 @@ describe('Test TimerActionTemplate success with config value', () => {
84
84
  const instance = wrapper.root;
85
85
 
86
86
  const texts = instance.findAllByType(Text);
87
- expect(texts).toHaveLength(7);
88
87
  expect(texts[0].props.children).toEqual('Timer');
89
88
  expect(texts[1].props.children).toEqual('Setting at 18:30');
90
89
 
91
90
  const switchButton = instance.findByType(Switch);
92
91
  expect(switchButton.props.value).toBeTruthy();
93
- await switchButton.props.onValueChange();
92
+ await act(async () => {
93
+ await switchButton.props.onValueChange();
94
+ });
94
95
  expect(mockDoAction).toBeCalled();
95
96
 
96
- const bottomScrollPicker = instance.findByType(ScrollPicker);
97
- expect(bottomScrollPicker).toBeDefined();
98
97
  const TouchableOpacities = instance.findAllByType(TouchableOpacity);
99
- await TouchableOpacities[0].props.onPress();
98
+ await act(async () => {
99
+ await TouchableOpacities[0].props.onPress();
100
+ });
100
101
 
101
102
  const dateTimePicker = instance.findByType(DateTimePickerModal);
102
103
  expect(dateTimePicker.props.isVisible).toBeTruthy();
@@ -119,17 +120,25 @@ describe('Test TimerActionTemplate success with config value', () => {
119
120
  });
120
121
  const instance = wrapper.root;
121
122
 
123
+ await act(async () => {
124
+ instance.findAllByType(TouchableOpacity)[0].props.onPress();
125
+ });
122
126
  const bottomScrollPicker = instance.findByType(ScrollPicker);
123
127
  expect(bottomScrollPicker).toBeDefined();
124
128
 
125
129
  const dateTimePicker = instance.findByType(DateTimePickerModal);
126
130
  expect(dateTimePicker.props.isVisible).toBeFalsy();
127
- await dateTimePicker.props.onConfirm();
128
-
131
+ await act(async () => {
132
+ await dateTimePicker.props.onConfirm();
133
+ });
129
134
  const TouchableOpacities = instance.findAllByType(TouchableOpacity);
130
135
  expect(TouchableOpacities).toHaveLength(3);
131
- await TouchableOpacities[0].props.onPress();
132
- await TouchableOpacities[2].props.onPress(3);
136
+ await act(async () => {
137
+ await TouchableOpacities[0].props.onPress();
138
+ });
139
+ await act(async () => {
140
+ await TouchableOpacities[2].props.onPress(3);
141
+ });
133
142
  expect(mockDoAction).toBeCalled();
134
143
  });
135
144
  });
@@ -69,7 +69,6 @@ describe('Test TimerActionTemplate without config value', () => {
69
69
  const instance = wrapper.root;
70
70
 
71
71
  const texts = instance.findAllByType(Text);
72
- expect(texts).toHaveLength(7);
73
72
  expect(texts[0].props.children).toEqual('Timer');
74
73
 
75
74
  const switchButton = instance.findByType(Switch);
@@ -1,5 +1,10 @@
1
1
  import React from 'react';
2
- import { TouchableOpacity, Switch, ActivityIndicator } from 'react-native';
2
+ import {
3
+ TouchableOpacity,
4
+ Switch,
5
+ ActivityIndicator,
6
+ ScrollView,
7
+ } from 'react-native';
3
8
  import renderer, { act } from 'react-test-renderer';
4
9
  import DateTimePickerModal from 'react-native-modal-datetime-picker';
5
10
  import moment from 'moment';
@@ -9,6 +14,9 @@ import Text from '../../Text';
9
14
  import { AccessibilityLabel } from '../../../configs/Constants';
10
15
  import { SCProvider } from '../../../context';
11
16
  import { mockSCStore } from '../../../context/mockStore';
17
+ import Slider from '@react-native-community/slider';
18
+ import { WheelColorPicker } from '../ColorPickerTemplate';
19
+ import RadioCircle from '../../RadioCircle';
12
20
 
13
21
  const wrapComponent = (actionGroup, mockDoAction, sensor) => (
14
22
  <SCProvider initState={mockSCStore({})}>
@@ -423,7 +431,6 @@ describe('Test ActionGroup', () => {
423
431
  const instance = wrapper.root;
424
432
 
425
433
  const texts = instance.findAllByType(Text);
426
- expect(texts).toHaveLength(7);
427
434
  expect(texts[0].props.children).toEqual('Timer');
428
435
 
429
436
  const switchButton = instance.findByType(Switch);
@@ -453,8 +460,8 @@ describe('Test ActionGroup', () => {
453
460
  );
454
461
  });
455
462
  const instance = wrapper.root;
456
- const texts = instance.findAllByType(Text);
457
- expect(texts).toHaveLength(4);
463
+ const buttons = instance.findAllByType(TouchableOpacity);
464
+ expect(buttons).toHaveLength(1);
458
465
  });
459
466
 
460
467
  it('render OptionsDropdownActionTemplate', async () => {
@@ -476,11 +483,12 @@ describe('Test ActionGroup', () => {
476
483
  );
477
484
  });
478
485
  const instance = wrapper.root;
479
- const texts = instance.findAllByType(Text);
480
- expect(texts).toHaveLength(7);
486
+ const options = instance.findAllByType(RadioCircle);
487
+ expect(options).toHaveLength(actionGroup.configuration.options.length);
481
488
  });
482
489
 
483
490
  it('render CurtainButtonTemplate', async () => {
491
+ // todo Bang remove
484
492
  Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
485
493
  const actionGroup = {
486
494
  template: 'curtain_action_template',
@@ -494,8 +502,8 @@ describe('Test ActionGroup', () => {
494
502
  );
495
503
  });
496
504
  const instance = wrapper.root;
497
- const texts = instance.findAllByType(Text);
498
- expect(texts).toHaveLength(5);
505
+ const texts = instance.findAllByType(TouchableOpacity);
506
+ expect(texts).toHaveLength(3);
499
507
  });
500
508
 
501
509
  it('render SmartTiviActionTemplate', async () => {
@@ -512,8 +520,8 @@ describe('Test ActionGroup', () => {
512
520
  );
513
521
  });
514
522
  const instance = wrapper.root;
515
- const texts = instance.findAllByType(Text);
516
- expect(texts).toHaveLength(4);
523
+ const buttons = instance.findAllByType(ScrollView);
524
+ expect(buttons).toHaveLength(1);
517
525
  });
518
526
 
519
527
  it('render ColorPickerTemplate', async () => {
@@ -530,8 +538,8 @@ describe('Test ActionGroup', () => {
530
538
  );
531
539
  });
532
540
  const instance = wrapper.root;
533
- const texts = instance.findAllByType(Text);
534
- expect(texts).toHaveLength(2);
541
+ const objs = instance.findAllByType(WheelColorPicker);
542
+ expect(objs).toHaveLength(1);
535
543
  });
536
544
 
537
545
  it('render SliderRangeTemplate', async () => {
@@ -548,8 +556,8 @@ describe('Test ActionGroup', () => {
548
556
  );
549
557
  });
550
558
  const instance = wrapper.root;
551
- const texts = instance.findAllByType(Text);
552
- expect(texts).toHaveLength(4);
559
+ const objs = instance.findAllByType(Slider);
560
+ expect(objs).toHaveLength(1);
553
561
  });
554
562
 
555
563
  it('render TwoButtonTemplate', async () => {
@@ -566,7 +574,7 @@ describe('Test ActionGroup', () => {
566
574
  );
567
575
  });
568
576
  const instance = wrapper.root;
569
- const texts = instance.findAllByType(Text);
570
- expect(texts).toHaveLength(5);
577
+ const buttons = instance.findAllByType(TouchableOpacity);
578
+ expect(buttons).toHaveLength(2);
571
579
  });
572
580
  });
@@ -90,7 +90,6 @@ describe('Test ActionTemplate', () => {
90
90
  tree = renderer.create(wrapComponent(data));
91
91
  });
92
92
  const instance = tree.root;
93
-
94
93
  const selectActionCard = instance.findByType(SelectActionCard);
95
94
  const modal = instance.findAllByType(Modal);
96
95
  await act(async () => {
@@ -98,12 +97,17 @@ describe('Test ActionTemplate', () => {
98
97
  });
99
98
  expect(modal[0].props.isVisible).toBe(true);
100
99
  });
100
+
101
101
  it('test onPressSelectAction', async () => {
102
102
  await act(async () => {
103
103
  tree = renderer.create(wrapComponent(data));
104
104
  });
105
105
  const instance = tree.root;
106
106
 
107
+ const card = instance.findByType(SelectActionCard);
108
+ await act(async () => {
109
+ card.props.onPress();
110
+ });
107
111
  const threeButtonAction = instance.findByType(ThreeButtonAction);
108
112
  await act(async () => {
109
113
  threeButtonAction.props.onPress({
@@ -8,7 +8,7 @@ describe('Test AlertAction', () => {
8
8
  it('create AlertAction', async () => {
9
9
  await act(async () => {
10
10
  tree = await renderer.create(
11
- <AlertAction visible={false} hideModal={true} title={''} />
11
+ <AlertAction visible={true} hideModal={jest.fn()} title={''} />
12
12
  );
13
13
  });
14
14
  const instance = tree.root;
@@ -21,7 +21,7 @@ describe('Test AlertAction', () => {
21
21
  tree = await renderer.create(
22
22
  <AlertAction
23
23
  visible={true}
24
- hideModal={true}
24
+ hideModal={jest.fn()}
25
25
  title={''}
26
26
  message={'message'}
27
27
  />
@@ -19,6 +19,6 @@ describe('Test ItemAutomate', () => {
19
19
  });
20
20
  const instance = tree.root;
21
21
  const texts = instance.findAllByType(Text);
22
- expect(texts).toHaveLength(4);
22
+ expect(texts[0].props.children).toEqual('Launch One-Tap');
23
23
  });
24
24
  });
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  import renderer, { act } from 'react-test-renderer';
3
3
  import CalendarComponent from '../';
4
4
  import { Calendar } from 'react-native-calendars';
5
- // eslint-disable-next-line no-unused-vars
6
- import BottomSheet from '../../BottomSheet';
7
5
  import { SCProvider } from '../../../context';
8
6
  import { mockSCStore } from '../../../context/mockStore';
9
7
 
@@ -14,9 +12,9 @@ jest.mock('react', () => {
14
12
  useState: jest.fn((init) => [init, mockSetState]),
15
13
  };
16
14
  });
17
- const wrapComponent = (route, navigation) => (
15
+ const wrapComponent = ({ route, isVisible, navigation }) => (
18
16
  <SCProvider initState={mockSCStore({})}>
19
- <CalendarComponent route={route} />
17
+ <CalendarComponent route={route} isVisible={isVisible} />
20
18
  </SCProvider>
21
19
  );
22
20
  describe('Test Calendar component', () => {
@@ -24,7 +22,7 @@ describe('Test Calendar component', () => {
24
22
 
25
23
  it('create Calendar', async () => {
26
24
  await act(async () => {
27
- tree = renderer.create(wrapComponent());
25
+ tree = renderer.create(wrapComponent({ isVisible: true }));
28
26
  });
29
27
  const instance = tree.root;
30
28
  const calendar = instance.findAllByType(Calendar);