@eohjsc/react-native-smart-city 0.3.8 → 0.3.9
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.
- package/README.md +36 -15
- package/package.json +10 -6
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +16 -4
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/ColorPickerTemplate.js +37 -24
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +1 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +8 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +6 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -3
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +22 -8
- package/src/commons/ActionGroup/TimerActionTemplate.js +11 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +1 -5
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +53 -78
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +36 -20
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +135 -0
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +76 -26
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +7 -3
- package/src/commons/Device/ItemDevice.js +34 -13
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +16 -12
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +3 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +1 -0
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +7 -2
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +25 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +96 -0
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +39 -0
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +118 -0
- package/src/commons/FieldTemplate/ChooseUserField/index.js +62 -0
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +30 -0
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +90 -0
- package/src/commons/FieldTemplate/PasscodeField/index.js +43 -0
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +13 -0
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +179 -0
- package/src/commons/FieldTemplate/ScheduleField/index.js +176 -0
- package/src/commons/Form/CurrencyInput.js +15 -1
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +2 -1
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HeaderAni/index.js +6 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +26 -47
- package/src/commons/MenuActionAddnew/index.js +1 -0
- package/src/commons/MenuActionList/index.js +1 -0
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +62 -0
- package/src/commons/PreventAccess/index.js +9 -1
- package/src/commons/Sharing/MemberList.js +10 -2
- package/src/commons/Sharing/WrapHeaderScrollable.js +2 -0
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +9 -2
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +4 -3
- package/src/configs/API.js +87 -143
- package/src/configs/Constants.js +61 -1
- package/src/configs/SCConfig.js +4 -0
- package/src/context/actionType.ts +10 -0
- package/src/context/mockStore.ts +11 -0
- package/src/context/reducer.ts +51 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +199 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +93 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +11 -20
- package/src/navigations/UnitStackStyles.js +21 -0
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +2 -0
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +1 -0
- package/src/screens/AddCommon/SelectUnit.js +1 -0
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +9 -5
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +8 -2
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +3 -1
- package/src/screens/AddNewAutoSmart/index.js +5 -2
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +42 -34
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +22 -22
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewDevice/index.js +1 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +46 -40
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +64 -10
- package/src/screens/AddNewGateway/SelectGateway.js +1 -0
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +2 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewGateway/index.js +1 -0
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +10 -24
- package/src/screens/AddNewOneTap/index.js +3 -2
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +5 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +17 -15
- package/src/screens/Device/__test__/detail.test.js +33 -86
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +44 -24
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +85 -26
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +6 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +20 -2
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +40 -23
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +4 -1
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/Explore/index.js +2 -0
- package/src/screens/GuestInfo/__test__/index.test.js +14 -41
- package/src/screens/GuestInfo/components/RecurringDetail.js +1 -0
- package/src/screens/GuestInfo/components/TemporaryDetail.js +2 -2
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +2 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +54 -35
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/components/QRScan/index.js +1 -0
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +19 -14
- package/src/screens/SelectUnit/__test__/index.test.js +12 -55
- package/src/screens/SelectUnit/index.js +9 -4
- package/src/screens/SetSchedule/index.js +15 -11
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/SharedUnit/index.js +2 -0
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +12 -11
- package/src/screens/Sharing/SelectPermission.js +121 -76
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/Sharing/hooks/index.js +3 -0
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +28 -0
- package/src/screens/SideMenuDetail/__test__/index.test.js +154 -0
- package/src/screens/SideMenuDetail/index.js +148 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +23 -17
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/EditSubUnit.js +15 -13
- package/src/screens/SubUnit/ManageSubUnit.js +13 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +29 -89
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +1 -0
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +22 -91
- package/src/screens/TDSGuide/index.js +4 -1
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +31 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +45 -23
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +4 -0
- package/src/screens/Unit/Summaries.js +18 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +98 -199
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +159 -49
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +91 -30
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +54 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +7 -1
- package/src/utils/I18n/translations/vi.json +8 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Setting/Location.js +30 -0
- package/src/utils/Utils.js +11 -7
- package/src/utils/__test__/Utils.test.js +12 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { create } from 'react-test-renderer';
|
|
3
|
+
import { act } from 'react-test-renderer';
|
|
4
|
+
import PreventAccess from '..';
|
|
5
|
+
import { TESTID } from '../../../configs/Constants';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
import Text from '../../Text';
|
|
9
|
+
|
|
10
|
+
const mockGoBack = jest.fn();
|
|
11
|
+
|
|
12
|
+
const wrapComponent = (headerBodyText, visible, hidePreventAccess) => (
|
|
13
|
+
<SCProvider initState={mockSCStore({})}>
|
|
14
|
+
<PreventAccess
|
|
15
|
+
headerBodyText={headerBodyText}
|
|
16
|
+
visible={visible}
|
|
17
|
+
hidePreventAccess={hidePreventAccess}
|
|
18
|
+
/>
|
|
19
|
+
</SCProvider>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
jest.mock('@react-navigation/native', () => {
|
|
23
|
+
return {
|
|
24
|
+
...jest.requireActual('@react-navigation/native'),
|
|
25
|
+
useRoute: jest.fn(),
|
|
26
|
+
useNavigation: () => ({
|
|
27
|
+
goBack: mockGoBack,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('Test PreventAccess.test', () => {
|
|
33
|
+
let tree;
|
|
34
|
+
let headerBodyText;
|
|
35
|
+
let visible;
|
|
36
|
+
let hidePreventAccess = () => {};
|
|
37
|
+
|
|
38
|
+
test('onItemClick MenuActionList', () => {
|
|
39
|
+
act(() => {
|
|
40
|
+
tree = create(wrapComponent(headerBodyText, visible, hidePreventAccess));
|
|
41
|
+
});
|
|
42
|
+
const instance = tree.root;
|
|
43
|
+
const text = instance.findAllByType(Text);
|
|
44
|
+
expect(text).toHaveLength(5);
|
|
45
|
+
const button1 = instance.find(
|
|
46
|
+
(el) => el.props.testID === TESTID.BUTTON_PREVENT_ACCESS
|
|
47
|
+
);
|
|
48
|
+
const button2 = instance.find(
|
|
49
|
+
(el) => el.props.testID === TESTID.TEXT_PREVENT_ACCESS
|
|
50
|
+
);
|
|
51
|
+
act(() => {
|
|
52
|
+
button1.props.onBackButtonPress();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
act(() => {
|
|
56
|
+
button2.props.onPress();
|
|
57
|
+
});
|
|
58
|
+
expect(button1).toBeDefined();
|
|
59
|
+
expect(button2).toBeDefined();
|
|
60
|
+
expect(mockGoBack).toHaveBeenCalled();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -7,6 +7,7 @@ import t from '../../hooks/Common/useTranslations';
|
|
|
7
7
|
import Text from '../Text';
|
|
8
8
|
import { Colors } from '../../configs';
|
|
9
9
|
import { styles } from './styles';
|
|
10
|
+
import { TESTID } from '../../configs/Constants';
|
|
10
11
|
|
|
11
12
|
const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
|
|
12
13
|
const { goBack } = useNavigation();
|
|
@@ -37,6 +38,7 @@ const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
|
|
|
37
38
|
transparent={true}
|
|
38
39
|
onBackButtonPress={handleBackPress}
|
|
39
40
|
style={styles.container}
|
|
41
|
+
testID={TESTID.BUTTON_PREVENT_ACCESS}
|
|
40
42
|
>
|
|
41
43
|
<View style={styles.popoverStyle}>
|
|
42
44
|
<View style={styles.actionTextWrap}>
|
|
@@ -48,7 +50,13 @@ const PreventAccess = memo(({ headerBodyText, visible, hidePreventAccess }) => {
|
|
|
48
50
|
</Text>
|
|
49
51
|
</View>
|
|
50
52
|
<View style={styles.endOfText}>
|
|
51
|
-
<Text
|
|
53
|
+
<Text
|
|
54
|
+
testID={TESTID.TEXT_PREVENT_ACCESS}
|
|
55
|
+
size={16}
|
|
56
|
+
bold
|
|
57
|
+
color={Colors.Primary}
|
|
58
|
+
onPress={handleDonePopup}
|
|
59
|
+
>
|
|
52
60
|
{dataText?.endOfText}
|
|
53
61
|
</Text>
|
|
54
62
|
</View>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { View, StyleSheet } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
-
import { Colors } from '../../configs';
|
|
4
|
+
import { Colors, Constants } from '../../configs';
|
|
5
5
|
import Text from '../../commons/Text';
|
|
6
6
|
import RowMember from './RowMember';
|
|
7
7
|
|
|
@@ -26,7 +26,9 @@ const MemberList = ({
|
|
|
26
26
|
/>
|
|
27
27
|
))}
|
|
28
28
|
{!dataMember.length && (
|
|
29
|
-
<
|
|
29
|
+
<View style={styles.viewEmpty}>
|
|
30
|
+
<Text style={styles.textCenter}>{t('no_member')}</Text>
|
|
31
|
+
</View>
|
|
30
32
|
)}
|
|
31
33
|
</View>
|
|
32
34
|
);
|
|
@@ -37,4 +39,10 @@ const styles = StyleSheet.create({
|
|
|
37
39
|
box: {
|
|
38
40
|
backgroundColor: Colors.White,
|
|
39
41
|
},
|
|
42
|
+
viewEmpty: {
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
height: Constants.height - 200,
|
|
46
|
+
backgroundColor: Colors.White,
|
|
47
|
+
},
|
|
40
48
|
});
|
|
@@ -13,6 +13,7 @@ import { isIphoneX } from 'react-native-iphone-x-helper';
|
|
|
13
13
|
import { Colors, Theme } from '../../configs';
|
|
14
14
|
import HeaderAni, { heightHeader } from '../../commons/HeaderAni';
|
|
15
15
|
import Text from '../../commons/Text';
|
|
16
|
+
import { TESTID } from '../../configs/Constants';
|
|
16
17
|
|
|
17
18
|
const WrapHeaderScrollable = ({
|
|
18
19
|
children,
|
|
@@ -59,6 +60,7 @@ const WrapHeaderScrollable = ({
|
|
|
59
60
|
onLeft={onGoBack}
|
|
60
61
|
/>
|
|
61
62
|
<Animated.ScrollView
|
|
63
|
+
testID={TESTID.ANIMATED_SCROLL}
|
|
62
64
|
scrollEventThrottle={16}
|
|
63
65
|
onScroll={Animated.event(
|
|
64
66
|
[{ nativeEvent: { contentOffset: { y: animatedScrollYValue } } }],
|
|
@@ -8,13 +8,13 @@ import ItemDevice from '../../Device/ItemDevice';
|
|
|
8
8
|
import ItemOneTap from '../OneTap/ItemOneTap';
|
|
9
9
|
import ItemAddNew from '../../Device/ItemAddNew';
|
|
10
10
|
import styles from './styles';
|
|
11
|
+
import { notImplemented } from '../../../utils/Utils';
|
|
11
12
|
|
|
12
13
|
const SubUnitFavorites = ({
|
|
13
14
|
isOwner,
|
|
14
15
|
unit,
|
|
15
16
|
favoriteDevices,
|
|
16
17
|
favoriteAutomates,
|
|
17
|
-
isGGHomeConnected,
|
|
18
18
|
wrapItemStyle,
|
|
19
19
|
}) => {
|
|
20
20
|
const t = useTranslations();
|
|
@@ -22,7 +22,7 @@ const SubUnitFavorites = ({
|
|
|
22
22
|
const { getStatus, serverDown } = useSensorsStatus(unit, favoriteDevices);
|
|
23
23
|
|
|
24
24
|
const handleOnAddNew = () => {
|
|
25
|
-
|
|
25
|
+
notImplemented(t);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -42,7 +42,6 @@ const SubUnitFavorites = ({
|
|
|
42
42
|
sensor={sensor}
|
|
43
43
|
unit={unit}
|
|
44
44
|
station={sensor.station}
|
|
45
|
-
isGGHomeConnected={isGGHomeConnected}
|
|
46
45
|
serverDown={serverDown}
|
|
47
46
|
status={getStatus(sensor)}
|
|
48
47
|
wrapStyle={wrapItemStyle}
|
|
@@ -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={
|
|
@@ -15,12 +15,18 @@ import { standardizeCameraScreenSize } from '../../utils/Utils';
|
|
|
15
15
|
import Routes from '../../utils/Route';
|
|
16
16
|
import FastImage from 'react-native-fast-image';
|
|
17
17
|
import MediaPlayerDetail from '../MediaPlayerDetail';
|
|
18
|
+
import {
|
|
19
|
+
keyPermission,
|
|
20
|
+
OpenSetting,
|
|
21
|
+
permitPermissionFunction,
|
|
22
|
+
} from '../../utils/Permission/common';
|
|
23
|
+
import { RESULTS } from 'react-native-permissions';
|
|
18
24
|
|
|
19
25
|
const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
|
|
20
26
|
Device.screenWidth - 32
|
|
21
27
|
);
|
|
22
28
|
|
|
23
|
-
const ShortDetailSubUnit = ({ unit, station
|
|
29
|
+
const ShortDetailSubUnit = ({ unit, station }) => {
|
|
24
30
|
const t = useTranslations();
|
|
25
31
|
const { navigate } = useNavigation();
|
|
26
32
|
|
|
@@ -71,13 +77,24 @@ const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
|
|
|
71
77
|
};
|
|
72
78
|
|
|
73
79
|
const handleOnAddNew = () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
permitPermissionFunction(keyPermission.CAMERA, (res) => {
|
|
81
|
+
if (res === RESULTS.GRANTED) {
|
|
82
|
+
navigate(Routes.AddDeviceStack, {
|
|
83
|
+
screen: Routes.ScanSensorQR,
|
|
84
|
+
params: {
|
|
85
|
+
station_id: station?.id,
|
|
86
|
+
unit_id: unit.id,
|
|
87
|
+
unit_name: unit.name,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (res === RESULTS.BLOCKED) {
|
|
93
|
+
OpenSetting(
|
|
94
|
+
t('camera_request_permission'),
|
|
95
|
+
t('camera_request_permission_des')
|
|
96
|
+
);
|
|
97
|
+
}
|
|
81
98
|
});
|
|
82
99
|
};
|
|
83
100
|
|
|
@@ -122,7 +139,6 @@ const ShortDetailSubUnit = ({ unit, station, isGGHomeConnected }) => {
|
|
|
122
139
|
sensor={sensor}
|
|
123
140
|
unit={unit}
|
|
124
141
|
station={station}
|
|
125
|
-
isGGHomeConnected={isGGHomeConnected}
|
|
126
142
|
serverDown={serverDown}
|
|
127
143
|
status={getStatus(sensor)}
|
|
128
144
|
/>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Image, View } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import mock from 'react-native-permissions/mock';
|
|
4
5
|
import { TESTID } from '../../../configs/Constants';
|
|
5
6
|
import { SCProvider } from '../../../context';
|
|
6
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
8
|
import ShortDetailSubUnit from '../ShortDetail';
|
|
8
9
|
import ItemAddNew from '../../Device/ItemAddNew';
|
|
9
10
|
import Routes from '../../../utils/Route';
|
|
11
|
+
import { keyPermission } from '../../../utils/Permission/common';
|
|
10
12
|
|
|
11
13
|
const wrapComponent = (props) => (
|
|
12
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -21,6 +23,10 @@ jest.mock('react', () => {
|
|
|
21
23
|
};
|
|
22
24
|
});
|
|
23
25
|
|
|
26
|
+
jest.mock('react-native-permissions', () => {
|
|
27
|
+
return mock;
|
|
28
|
+
});
|
|
29
|
+
|
|
24
30
|
const mockedNavigate = jest.fn();
|
|
25
31
|
jest.mock('@react-navigation/native', () => {
|
|
26
32
|
return {
|
|
@@ -145,10 +151,10 @@ describe('test ShortDetail Subunit', () => {
|
|
|
145
151
|
(item) =>
|
|
146
152
|
item.props.testID === TESTID.SUB_UNIT_DEVICES && item.type === View
|
|
147
153
|
);
|
|
148
|
-
expect(itemDevice.length).toBe(
|
|
154
|
+
expect(itemDevice.length).toBe(0);
|
|
149
155
|
});
|
|
150
156
|
|
|
151
|
-
test('render ShortDetail add new device', () => {
|
|
157
|
+
test('render ShortDetail add new device', async () => {
|
|
152
158
|
act(() => {
|
|
153
159
|
tree = create(wrapComponent(props));
|
|
154
160
|
});
|
|
@@ -157,6 +163,7 @@ describe('test ShortDetail Subunit', () => {
|
|
|
157
163
|
act(() => {
|
|
158
164
|
buttonAddNew.props.onAddNew();
|
|
159
165
|
});
|
|
166
|
+
await mock.request(keyPermission.CAMERA);
|
|
160
167
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddDeviceStack, {
|
|
161
168
|
screen: Routes.ScanSensorQR,
|
|
162
169
|
params: {
|