@eohjsc/react-native-smart-city 0.3.4 → 0.3.7
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 +15 -36
- package/package.json +5 -9
- package/react-native-smart-city.podspec +0 -1
- package/src/commons/Action/ItemQuickAction.js +4 -16
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -11
- package/src/commons/ActionGroup/ColorPickerTemplate.js +24 -37
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +5 -10
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -12
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +0 -4
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -14
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +0 -1
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +2 -8
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +10 -10
- package/src/commons/ActionGroup/OnOffTemplate/index.js +2 -3
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +9 -7
- package/src/commons/ActionGroup/SliderRangeTemplate.js +2 -6
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -22
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -11
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +5 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +4 -53
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +83 -3
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +14 -14
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +78 -53
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +20 -36
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +57 -1
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -58
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -49
- package/src/commons/ActionGroup/__test__/index.test.js +4 -142
- package/src/commons/Auth/AccountList.js +1 -1
- package/src/commons/Automate/ItemAutomate.js +3 -1
- package/src/commons/Connecting/__test__/Connecting.test.js +2 -19
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +3 -7
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +11 -8
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +3 -136
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +2 -3
- package/src/commons/ConnectingProcess/index.js +25 -75
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +13 -16
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +5 -0
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/HistoryChart.js +3 -7
- package/src/commons/Device/ItemDevice.js +12 -19
- package/src/commons/Device/LinearChart.js +0 -15
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +12 -16
- package/src/commons/Device/PMSensor/PMSensorIndicatorStyles.js +0 -3
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +0 -1
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -7
- package/src/commons/Explore/__test__/CityItem.test.js +54 -33
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Form/TextInputPassword.js +1 -1
- package/src/commons/FullLoading/index.js +1 -2
- package/src/commons/Header/HeaderCustom.js +1 -2
- package/src/commons/HeaderAni/index.js +1 -6
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +6 -0
- package/src/commons/MediaPlayerDetail/index.js +47 -25
- package/src/commons/MenuActionAddnew/index.js +0 -1
- package/src/commons/MenuActionList/index.js +0 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/PreventAccess/index.js +1 -9
- package/src/commons/Sharing/MemberList.js +2 -10
- package/src/commons/Sharing/WrapHeaderScrollable.js +0 -2
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +3 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +35 -8
- package/src/commons/SubUnit/OneTap/index.js +2 -1
- package/src/commons/SubUnit/ShortDetail.js +9 -25
- package/src/commons/SubUnit/__test__/Item.test.js +1 -0
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -9
- package/src/commons/Unit/SharedUnit.js +0 -1
- package/src/commons/Unit/__test__/SharedUnit.test.js +183 -38
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +13 -2
- package/src/commons/UnitSummary/ConfigHistoryChart.js +13 -22
- package/src/commons/WheelDateTimePicker/index.js +3 -4
- package/src/configs/API.js +143 -87
- package/src/configs/Constants.js +2 -57
- package/src/configs/SCConfig.js +0 -4
- package/src/context/actionType.ts +0 -8
- package/src/context/mockStore.ts +0 -10
- package/src/context/reducer.ts +2 -38
- package/src/hooks/Common/index.js +0 -2
- package/src/hooks/Common/useGetIdUser.js +5 -1
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/useReceiveNotifications.js +5 -9
- package/src/iot/Monitor.js +2 -3
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +49 -75
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +48 -95
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -18
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +177 -36
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/navigations/UnitStack.js +20 -11
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/FilterPopup.js +0 -2
- package/src/screens/ActivityLog/__test__/index.test.js +23 -38
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +90 -51
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/SelectSubUnit.js +0 -1
- package/src/screens/AddCommon/SelectUnit.js +0 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +24 -13
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +33 -9
- package/src/screens/AddLocationMaps/index.js +5 -9
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SelectSensorDevices.js +2 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +91 -10
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +26 -40
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +1 -3
- package/src/screens/AddNewAutoSmart/index.js +2 -5
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -42
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +4 -0
- 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 +0 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +17 -23
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +4 -7
- package/src/screens/AddNewGateway/SelectGateway.js +0 -1
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +0 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +6 -4
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +29 -5
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +4 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +4 -0
- package/src/screens/AddNewGateway/index.js +0 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +24 -10
- package/src/screens/AddNewOneTap/index.js +2 -3
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +9 -6
- package/src/screens/Automate/__test__/index.test.js +12 -7
- package/src/screens/Automate/index.js +3 -5
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +8 -36
- package/src/screens/ConfirmUnitDeletion/index.js +1 -7
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +22 -71
- package/src/screens/Device/EditDevice/index.js +15 -17
- package/src/screens/Device/__test__/detail.test.js +86 -33
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +0 -1
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +24 -80
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +9 -5
- package/src/screens/DeviceInfo/__test__/index.test.js +2 -0
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -6
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +19 -7
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +2 -20
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +23 -40
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EmergencySetting/index.js +1 -4
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +25 -41
- package/src/screens/Explore/index.js +0 -2
- package/src/screens/GuestInfo/__test__/index.test.js +41 -14
- package/src/screens/GuestInfo/components/RecurringDetail.js +0 -1
- 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 +12 -8
- package/src/screens/HanetCamera/__test__/Detail.test.js +42 -27
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -8
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +32 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -3
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +35 -43
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +21 -10
- 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 +22 -33
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +45 -44
- package/src/screens/ManageAccess/hooks/index.js +4 -7
- package/src/screens/ManageAccess/index.js +1 -2
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +12 -35
- package/src/screens/MoveToAnotherSubUnit/index.js +6 -6
- package/src/screens/Notification/__test__/Notification.test.js +25 -14
- package/src/screens/Notification/__test__/NotificationItem.test.js +7 -8
- package/src/screens/Notification/components/NotificationItem.js +20 -17
- package/src/screens/Notification/index.js +2 -9
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +2 -87
- package/src/screens/PlayBackCamera/index.js +6 -22
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +20 -7
- package/src/screens/ScanChipQR/components/QRScan/index.js +0 -1
- package/src/screens/ScanChipQR/hooks/index.js +16 -15
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +24 -8
- package/src/screens/ScriptDetail/__test__/index.test.js +86 -17
- package/src/screens/ScriptDetail/index.js +14 -19
- package/src/screens/SelectUnit/__test__/index.test.js +55 -12
- package/src/screens/SelectUnit/index.js +4 -9
- package/src/screens/SetSchedule/index.js +11 -15
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +2 -0
- package/src/screens/SharedUnit/index.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +12 -10
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/MemberList.js +11 -12
- package/src/screens/Sharing/SelectPermission.js +76 -121
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +29 -47
- package/src/screens/Sharing/__test__/MemberList.test.js +127 -13
- package/src/screens/Sharing/__test__/SelectPermission.test.js +38 -28
- package/src/screens/Sharing/__test__/SelectUser.test.js +38 -17
- package/src/screens/Sharing/hooks/index.js +0 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -3
- package/src/screens/SmartIr/components/SelectBrand.js +1 -1
- package/src/screens/SubUnit/AddSubUnit.js +17 -23
- package/src/screens/SubUnit/Detail.js +2 -1
- package/src/screens/SubUnit/EditSubUnit.js +13 -15
- package/src/screens/SubUnit/ManageSubUnit.js +7 -13
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +89 -29
- package/src/screens/SubUnit/__test__/Detail.test.js +8 -31
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +89 -21
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +1 -27
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +45 -48
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/AddLGDevice.js +0 -1
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +91 -22
- package/src/screens/TDSGuide/index.js +1 -4
- package/src/screens/UVIndexGuide/index.js +1 -1
- package/src/screens/Unit/ChooseLocation.js +14 -7
- package/src/screens/Unit/Detail.js +75 -30
- package/src/screens/Unit/ManageUnit.js +0 -1
- package/src/screens/Unit/SelectAddress.js +23 -45
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Station/index.js +0 -4
- package/src/screens/Unit/Summaries.js +2 -18
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +29 -24
- package/src/screens/Unit/__test__/ChooseLocation.test.js +14 -27
- package/src/screens/Unit/__test__/Detail.test.js +200 -99
- package/src/screens/Unit/__test__/ManageUnit.test.js +42 -18
- package/src/screens/Unit/__test__/SelectAddress.test.js +49 -159
- package/src/screens/Unit/__test__/SmartAccount.test.js +9 -17
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +1 -0
- package/src/screens/Unit/components/MyUnitDevice/index.js +4 -4
- package/src/screens/Unit/components/SharedUnit/index.js +0 -1
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +2 -2
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +34 -31
- package/src/screens/Unit/styles.js +0 -4
- package/src/screens/UnitSummary/__test__/index.test.js +30 -91
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +2 -31
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +4 -7
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +13 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -14
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -11
- package/src/screens/UnitSummary/components/RunningDevices/index.js +10 -7
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -10
- package/src/screens/UnitSummary/index.js +1 -15
- package/src/screens/WaterQualityGuide/index.js +1 -1
- package/src/utils/Apis/axios.js +31 -54
- package/src/utils/Converter/time.js +18 -0
- package/src/utils/I18n/translations/en.json +1 -7
- package/src/utils/I18n/translations/vi.json +1 -8
- package/src/utils/Route/index.js +0 -1
- package/src/utils/Utils.js +7 -11
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +0 -24
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplateWithNullConfigValue.test.js +0 -60
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -77
- package/src/commons/Calendar/__test__/Calendar.test.js +0 -33
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +0 -58
- package/src/commons/FieldTemplate/ChooseUserField/ChooseFieldStyles.js +0 -25
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopup.js +0 -96
- package/src/commons/FieldTemplate/ChooseUserField/ChoosePopupStyles.js +0 -39
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +0 -118
- package/src/commons/FieldTemplate/ChooseUserField/index.js +0 -62
- package/src/commons/FieldTemplate/PasscodeField/PasscodeFieldStyles.js +0 -30
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -90
- package/src/commons/FieldTemplate/PasscodeField/index.js +0 -43
- package/src/commons/FieldTemplate/ScheduleField/ScheduleFieldStyles.js +0 -13
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -179
- package/src/commons/FieldTemplate/ScheduleField/index.js +0 -176
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +0 -62
- package/src/hooks/Common/useGGHomeDeviceConnected.js +0 -16
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +0 -198
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +0 -198
- package/src/hooks/IoT/index.js +0 -4
- package/src/hooks/IoT/useGGHomeConnection.js +0 -91
- package/src/hooks/IoT/useRemoteControl.js +0 -79
- package/src/hooks/index.js +0 -4
- package/src/navigations/UnitStackStyles.js +0 -21
- package/src/screens/Sharing/__test__/MemberList2.test.js +0 -80
- package/src/screens/SideMenuDetail/SideMenuDetailStyles.js +0 -28
- package/src/screens/SideMenuDetail/__test__/index.test.js +0 -154
- package/src/screens/SideMenuDetail/index.js +0 -148
- package/src/screens/Unit/__test__/Summaries.test.js +0 -100
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +0 -36
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -54
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +0 -50
- package/src/utils/Permission/common.js +0 -67
- package/src/utils/Setting/Location.js +0 -30
- package/src/utils/__test__/Utils.test.js +0 -12
|
@@ -20,14 +20,13 @@ import Routes from '../../utils/Route';
|
|
|
20
20
|
import { RowItem } from '../../commons/RowItem';
|
|
21
21
|
import NoSubUnitImage from '../../../assets/images/Illustrations.svg';
|
|
22
22
|
import useManageSubUnit from './hooks/useManageSubUnit';
|
|
23
|
-
import { TESTID } from '../../configs/Constants';
|
|
24
23
|
|
|
25
24
|
const ManageSubUnit = memo((props) => {
|
|
26
25
|
const t = useTranslations();
|
|
27
26
|
const { unit } = props.route.params;
|
|
28
27
|
const navigation = useNavigation();
|
|
29
28
|
const isFocused = useIsFocused();
|
|
30
|
-
const {
|
|
29
|
+
const { station, isRefresh, isLoading, onRefresh } = useManageSubUnit(unit);
|
|
31
30
|
|
|
32
31
|
const addSubUnit = useCallback(() => {
|
|
33
32
|
navigation.navigate(Routes.AddSubUnitStack, {
|
|
@@ -36,7 +35,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
36
35
|
});
|
|
37
36
|
}, [navigation, unit]);
|
|
38
37
|
|
|
39
|
-
const goToEditSubUnit = (station) => {
|
|
38
|
+
const goToEditSubUnit = (station, unit) => {
|
|
40
39
|
navigation.navigate(Routes.UnitStack, {
|
|
41
40
|
screen: Routes.EditSubUnit,
|
|
42
41
|
params: {
|
|
@@ -49,11 +48,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
49
48
|
const rightComponent = useMemo(
|
|
50
49
|
() => (
|
|
51
50
|
<View style={styles.rightComponent}>
|
|
52
|
-
<TouchableOpacity
|
|
53
|
-
testID={TESTID.ADD_SUB_UNIT}
|
|
54
|
-
onPress={addSubUnit}
|
|
55
|
-
style={styles.headerButton}
|
|
56
|
-
>
|
|
51
|
+
<TouchableOpacity onPress={addSubUnit} style={styles.headerButton}>
|
|
57
52
|
<Icon name={'plus'} size={27} color={Colors.Black} />
|
|
58
53
|
</TouchableOpacity>
|
|
59
54
|
<TouchableOpacity
|
|
@@ -86,11 +81,10 @@ const ManageSubUnit = memo((props) => {
|
|
|
86
81
|
refreshControl={
|
|
87
82
|
<RefreshControl refreshing={false} onRefresh={onRefresh} />
|
|
88
83
|
}
|
|
89
|
-
scrollIndicatorInsets={{ right: 1 }}
|
|
90
84
|
>
|
|
91
85
|
<View>
|
|
92
|
-
{!!
|
|
93
|
-
|
|
86
|
+
{!!station.length &&
|
|
87
|
+
station.map((item, index) => {
|
|
94
88
|
return (
|
|
95
89
|
<RowItem
|
|
96
90
|
type={'noneBG'}
|
|
@@ -105,7 +99,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
105
99
|
}
|
|
106
100
|
text={item.name}
|
|
107
101
|
subtext={`${
|
|
108
|
-
item.
|
|
102
|
+
item.sensors ? item.sensors.length : '0'
|
|
109
103
|
} devices`}
|
|
110
104
|
onPress={() => goToEditSubUnit(item, unit)}
|
|
111
105
|
rightComponent={
|
|
@@ -118,7 +112,7 @@ const ManageSubUnit = memo((props) => {
|
|
|
118
112
|
/>
|
|
119
113
|
);
|
|
120
114
|
})}
|
|
121
|
-
{!
|
|
115
|
+
{!station.length && !isRefresh && !isLoading && (
|
|
122
116
|
<View style={styles.NoSubUnit}>
|
|
123
117
|
<NoSubUnitImage />
|
|
124
118
|
<Text semibold type="H4" center>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Image, TouchableWithoutFeedback } from 'react-native';
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import axios from 'axios';
|
|
5
4
|
import { ImagePicker, ViewButtonBottom } from '../../../commons';
|
|
6
5
|
import { act, create } from 'react-test-renderer';
|
|
7
6
|
import Toast from 'react-native-toast-message';
|
|
@@ -12,8 +11,6 @@ import AddSubUnit from '../AddSubUnit';
|
|
|
12
11
|
import { getTranslate } from '../../../utils/I18n';
|
|
13
12
|
import { SCProvider } from '../../../context';
|
|
14
13
|
import { mockSCStore } from '../../../context/mockStore';
|
|
15
|
-
import api from '../../../utils/Apis/axios';
|
|
16
|
-
import { API } from '../../../configs';
|
|
17
14
|
|
|
18
15
|
const wrapComponent = (route) => (
|
|
19
16
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -25,7 +22,7 @@ const mockedNavigate = jest.fn();
|
|
|
25
22
|
const mockedDispatch = jest.fn();
|
|
26
23
|
const mockedGoBack = jest.fn();
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
jest.mock('axios');
|
|
29
26
|
jest.mock('react-native-toast-message');
|
|
30
27
|
jest.mock('react-native-image-resizer');
|
|
31
28
|
|
|
@@ -36,20 +33,13 @@ jest.mock('react-redux', () => {
|
|
|
36
33
|
};
|
|
37
34
|
});
|
|
38
35
|
|
|
39
|
-
const mockNavigationDispatch = jest.fn();
|
|
40
|
-
const mockReplace = jest.fn();
|
|
41
|
-
|
|
42
36
|
jest.mock('@react-navigation/native', () => {
|
|
43
37
|
return {
|
|
44
38
|
...jest.requireActual('@react-navigation/native'),
|
|
45
39
|
useNavigation: () => ({
|
|
46
40
|
navigate: mockedNavigate,
|
|
47
41
|
goBack: mockedGoBack,
|
|
48
|
-
dispatch: mockNavigationDispatch,
|
|
49
42
|
}),
|
|
50
|
-
StackActions: {
|
|
51
|
-
replace: () => mockReplace,
|
|
52
|
-
},
|
|
53
43
|
};
|
|
54
44
|
});
|
|
55
45
|
|
|
@@ -70,8 +60,8 @@ describe('Test AddSubUnit', () => {
|
|
|
70
60
|
afterEach(() => {
|
|
71
61
|
mockedDispatch.mockClear();
|
|
72
62
|
mockedNavigate.mockClear();
|
|
73
|
-
mockNavigationDispatch.mockClear();
|
|
74
63
|
Toast.show.mockClear();
|
|
64
|
+
axios.post.mockClear();
|
|
75
65
|
});
|
|
76
66
|
let tree;
|
|
77
67
|
|
|
@@ -149,7 +139,15 @@ describe('Test AddSubUnit', () => {
|
|
|
149
139
|
});
|
|
150
140
|
|
|
151
141
|
test('validateData then send api success', async () => {
|
|
152
|
-
|
|
142
|
+
const response = {
|
|
143
|
+
status: 200,
|
|
144
|
+
data: {},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
axios.post.mockImplementation(async () => {
|
|
148
|
+
return response;
|
|
149
|
+
});
|
|
150
|
+
|
|
153
151
|
await act(async () => {
|
|
154
152
|
tree = await create(wrapComponent(route));
|
|
155
153
|
});
|
|
@@ -158,16 +156,33 @@ describe('Test AddSubUnit', () => {
|
|
|
158
156
|
await act(async () => {
|
|
159
157
|
await viewButtonBottom.props.onRightClick();
|
|
160
158
|
});
|
|
159
|
+
expect(axios.post).toHaveBeenCalled();
|
|
160
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
161
|
+
screen: Routes.UnitDetail,
|
|
162
|
+
params: {
|
|
163
|
+
unitId: route.params.unit.id,
|
|
164
|
+
unitData: route.params.unit,
|
|
165
|
+
routeName: 'DashboardStack',
|
|
166
|
+
isAddSubUnit: true,
|
|
167
|
+
},
|
|
168
|
+
});
|
|
161
169
|
expect(Toast.show).toHaveBeenCalledWith({
|
|
162
|
-
type: '
|
|
170
|
+
type: 'success',
|
|
163
171
|
position: 'bottom',
|
|
164
|
-
text1: getTranslate('en', '
|
|
172
|
+
text1: getTranslate('en', 'text_create_sub_unit_success'),
|
|
165
173
|
visibilityTime: 1000,
|
|
166
174
|
});
|
|
167
175
|
});
|
|
168
176
|
|
|
169
177
|
test('validateData then send api fail', async () => {
|
|
170
|
-
|
|
178
|
+
const response = {
|
|
179
|
+
data: {},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
axios.post.mockImplementation(async () => {
|
|
183
|
+
return response;
|
|
184
|
+
});
|
|
185
|
+
|
|
171
186
|
await act(async () => {
|
|
172
187
|
tree = await create(wrapComponent(route));
|
|
173
188
|
});
|
|
@@ -176,6 +191,7 @@ describe('Test AddSubUnit', () => {
|
|
|
176
191
|
await act(async () => {
|
|
177
192
|
await viewButtonBottom.props.onRightClick();
|
|
178
193
|
});
|
|
194
|
+
expect(axios.post).toHaveBeenCalled();
|
|
179
195
|
expect(Toast.show).toHaveBeenCalledWith({
|
|
180
196
|
type: 'error',
|
|
181
197
|
position: 'bottom',
|
|
@@ -185,14 +201,23 @@ describe('Test AddSubUnit', () => {
|
|
|
185
201
|
});
|
|
186
202
|
|
|
187
203
|
test('test create Unit', async () => {
|
|
204
|
+
const response = {
|
|
205
|
+
success: true,
|
|
206
|
+
status: 200,
|
|
207
|
+
data: {
|
|
208
|
+
id: 2,
|
|
209
|
+
},
|
|
210
|
+
};
|
|
188
211
|
route.params = {
|
|
189
212
|
...route.params,
|
|
190
213
|
location: 'Unit address',
|
|
191
214
|
isAddUnit: true,
|
|
192
215
|
};
|
|
193
|
-
|
|
194
|
-
|
|
216
|
+
|
|
217
|
+
axios.post.mockImplementation(async () => {
|
|
218
|
+
return response;
|
|
195
219
|
});
|
|
220
|
+
|
|
196
221
|
await act(async () => {
|
|
197
222
|
tree = await create(wrapComponent(route));
|
|
198
223
|
});
|
|
@@ -203,7 +228,14 @@ describe('Test AddSubUnit', () => {
|
|
|
203
228
|
await act(async () => {
|
|
204
229
|
await viewButtonBottom.props.onRightClick();
|
|
205
230
|
});
|
|
206
|
-
expect(
|
|
231
|
+
expect(axios.post).toHaveBeenCalled();
|
|
232
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
233
|
+
screen: Routes.UnitDetail,
|
|
234
|
+
params: {
|
|
235
|
+
unitId: response.data.id,
|
|
236
|
+
routeName: Routes.DashboardStack,
|
|
237
|
+
},
|
|
238
|
+
});
|
|
207
239
|
});
|
|
208
240
|
|
|
209
241
|
test('test choose Location', async () => {
|
|
@@ -227,20 +259,31 @@ describe('Test AddSubUnit', () => {
|
|
|
227
259
|
});
|
|
228
260
|
|
|
229
261
|
test('test create Unit Fail', async () => {
|
|
262
|
+
const response = {
|
|
263
|
+
success: false,
|
|
264
|
+
status: 400,
|
|
265
|
+
};
|
|
230
266
|
route.params = {
|
|
231
267
|
...route.params,
|
|
232
268
|
location: 'Unit address',
|
|
233
269
|
isAddUnit: true,
|
|
234
270
|
};
|
|
235
|
-
|
|
271
|
+
|
|
272
|
+
axios.post.mockImplementation(async () => {
|
|
273
|
+
return response;
|
|
274
|
+
});
|
|
275
|
+
|
|
236
276
|
await act(async () => {
|
|
237
277
|
tree = await create(wrapComponent(route));
|
|
238
278
|
});
|
|
279
|
+
|
|
239
280
|
const instance = tree.root;
|
|
240
281
|
const viewButtonBottom = await makeValidateData(instance);
|
|
282
|
+
|
|
241
283
|
await act(async () => {
|
|
242
284
|
await viewButtonBottom.props.onRightClick();
|
|
243
285
|
});
|
|
286
|
+
expect(axios.post).toHaveBeenCalled();
|
|
244
287
|
expect(Toast.show).toHaveBeenCalledWith({
|
|
245
288
|
type: 'error',
|
|
246
289
|
position: 'bottom',
|
|
@@ -250,11 +293,20 @@ describe('Test AddSubUnit', () => {
|
|
|
250
293
|
});
|
|
251
294
|
|
|
252
295
|
test('test create sub-unit type AddHassiDevice', async () => {
|
|
296
|
+
const response = {
|
|
297
|
+
status: 200,
|
|
298
|
+
success: true,
|
|
299
|
+
data: {},
|
|
300
|
+
};
|
|
253
301
|
route.params = {
|
|
254
302
|
...route.params,
|
|
255
303
|
addType: 'AddHassiDevice',
|
|
256
304
|
};
|
|
257
|
-
|
|
305
|
+
|
|
306
|
+
axios.post.mockImplementation(async () => {
|
|
307
|
+
return response;
|
|
308
|
+
});
|
|
309
|
+
|
|
258
310
|
await act(async () => {
|
|
259
311
|
tree = await create(wrapComponent(route));
|
|
260
312
|
});
|
|
@@ -263,15 +315,25 @@ describe('Test AddSubUnit', () => {
|
|
|
263
315
|
await act(async () => {
|
|
264
316
|
await viewButtonBottom.props.onRightClick();
|
|
265
317
|
});
|
|
318
|
+
expect(axios.post).toHaveBeenCalled();
|
|
266
319
|
expect(mockedGoBack).toHaveBeenCalled();
|
|
267
320
|
});
|
|
268
321
|
|
|
269
322
|
test('test create sub-unit type AddNewGateway', async () => {
|
|
323
|
+
const response = {
|
|
324
|
+
status: 200,
|
|
325
|
+
success: true,
|
|
326
|
+
data: {},
|
|
327
|
+
};
|
|
270
328
|
route.params = {
|
|
271
329
|
...route.params,
|
|
272
330
|
addType: 'AddNewGateway',
|
|
273
331
|
};
|
|
274
|
-
|
|
332
|
+
|
|
333
|
+
axios.post.mockImplementation(async () => {
|
|
334
|
+
return response;
|
|
335
|
+
});
|
|
336
|
+
|
|
275
337
|
await act(async () => {
|
|
276
338
|
tree = await create(wrapComponent(route));
|
|
277
339
|
});
|
|
@@ -280,11 +342,9 @@ describe('Test AddSubUnit', () => {
|
|
|
280
342
|
await act(async () => {
|
|
281
343
|
await viewButtonBottom.props.onRightClick();
|
|
282
344
|
});
|
|
283
|
-
expect(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
);
|
|
345
|
+
expect(axios.post).toHaveBeenCalled();
|
|
346
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddCommonSelectSubUnit, {
|
|
347
|
+
...route.params,
|
|
348
|
+
});
|
|
289
349
|
});
|
|
290
350
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
2
|
+
import axios from 'axios';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { useSelector } from 'react-redux';
|
|
4
5
|
import { act, create } from 'react-test-renderer';
|
|
@@ -9,8 +10,6 @@ import Routes from '../../../utils/Route';
|
|
|
9
10
|
import WrapParallaxScrollView from '../../../commons/WrapParallaxScrollView';
|
|
10
11
|
import { SCProvider } from '../../../context';
|
|
11
12
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
-
import { TESTID } from '../../../configs/Constants';
|
|
13
|
-
import { TouchableOpacity } from 'react-native';
|
|
14
13
|
|
|
15
14
|
const mockedNavigate = jest.fn();
|
|
16
15
|
const mockedDispatch = jest.fn();
|
|
@@ -18,6 +17,8 @@ const mockedDangerouslyGetState = jest.fn();
|
|
|
18
17
|
const mockedDangerouslyGetStatePop = jest.fn();
|
|
19
18
|
const mockedPop = jest.fn();
|
|
20
19
|
|
|
20
|
+
jest.mock('axios');
|
|
21
|
+
|
|
21
22
|
jest.mock('react-redux', () => {
|
|
22
23
|
return {
|
|
23
24
|
...jest.requireActual('react-redux'),
|
|
@@ -106,6 +107,8 @@ describe('Test SubUnitDetail', () => {
|
|
|
106
107
|
afterEach(() => {
|
|
107
108
|
mockedDispatch.mockClear();
|
|
108
109
|
Toast.show.mockClear();
|
|
110
|
+
axios.delete.mockClear();
|
|
111
|
+
axios.patch.mockClear();
|
|
109
112
|
});
|
|
110
113
|
let tree;
|
|
111
114
|
|
|
@@ -137,33 +140,7 @@ describe('Test SubUnitDetail', () => {
|
|
|
137
140
|
});
|
|
138
141
|
expect(mockedDangerouslyGetStatePop).toHaveBeenCalledWith(2);
|
|
139
142
|
});
|
|
140
|
-
|
|
141
|
-
test('click Menu ActionMore', async () => {
|
|
142
|
-
mockedDangerouslyGetState.mockImplementation(() => ({
|
|
143
|
-
routes: [
|
|
144
|
-
{ name: 'route 1' },
|
|
145
|
-
{ name: 'route 2' },
|
|
146
|
-
{ name: Routes.AddSubUnitStack },
|
|
147
|
-
],
|
|
148
|
-
}));
|
|
149
|
-
|
|
150
|
-
await act(async () => {
|
|
151
|
-
tree = await create(wrapComponent(route));
|
|
152
|
-
});
|
|
153
|
-
const instance = tree.root;
|
|
154
|
-
const button = instance.find(
|
|
155
|
-
(el) =>
|
|
156
|
-
el.props.testID === TESTID.HEADER_UNIT_BUTTON_BACK &&
|
|
157
|
-
el.type === TouchableOpacity
|
|
158
|
-
);
|
|
159
|
-
act(() => {
|
|
160
|
-
button.props.onPress();
|
|
161
|
-
});
|
|
162
|
-
const buttonOnActionPress = instance.findAll(
|
|
163
|
-
(el) =>
|
|
164
|
-
el.props.testID === TESTID.HEADER_UNIT_BUTTON_MORE &&
|
|
165
|
-
el.type === TouchableOpacity
|
|
166
|
-
);
|
|
167
|
-
expect(buttonOnActionPress).toHaveLength(1);
|
|
168
|
-
});
|
|
169
143
|
});
|
|
144
|
+
|
|
145
|
+
// 71-72,78-84,90-91,97
|
|
146
|
+
// 78-84,97
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { TouchableOpacity, Image } from 'react-native';
|
|
4
|
-
import
|
|
4
|
+
import axios from 'axios';
|
|
5
5
|
import { AlertAction, ImagePicker, ViewButtonBottom } from '../../../commons';
|
|
6
6
|
import { API } from '../../../configs';
|
|
7
7
|
import { useSelector } from 'react-redux';
|
|
@@ -16,14 +16,13 @@ import _TextInput from '../../../commons/Form/TextInput';
|
|
|
16
16
|
import { SCProvider } from '../../../context';
|
|
17
17
|
import { mockSCStore } from '../../../context/mockStore';
|
|
18
18
|
import { getTranslate } from '../../../utils/I18n';
|
|
19
|
-
import api from '../../../utils/Apis/axios';
|
|
20
19
|
|
|
21
20
|
const mockedNavigate = jest.fn();
|
|
22
21
|
const mockedDispatch = jest.fn();
|
|
23
22
|
const mockedDangerouslyGetState = jest.fn();
|
|
24
23
|
const mockedPop = jest.fn();
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
jest.mock('axios');
|
|
27
26
|
jest.mock('react-native-toast-message');
|
|
28
27
|
|
|
29
28
|
jest.mock('react-redux', () => {
|
|
@@ -92,6 +91,8 @@ describe('Test EditSubUnit', () => {
|
|
|
92
91
|
afterEach(() => {
|
|
93
92
|
mockedDispatch.mockClear();
|
|
94
93
|
Toast.show.mockClear();
|
|
94
|
+
axios.delete.mockClear();
|
|
95
|
+
axios.patch.mockClear();
|
|
95
96
|
});
|
|
96
97
|
let tree;
|
|
97
98
|
|
|
@@ -110,9 +111,12 @@ describe('Test EditSubUnit', () => {
|
|
|
110
111
|
});
|
|
111
112
|
|
|
112
113
|
test('alertAction rightButtonClick success, previous screen Routes.UnitDetail', async () => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
const response = {
|
|
115
|
+
status: 200,
|
|
116
|
+
};
|
|
117
|
+
axios.delete.mockImplementation(async () => {
|
|
118
|
+
return response;
|
|
119
|
+
});
|
|
116
120
|
|
|
117
121
|
mockedDangerouslyGetState.mockImplementation(() => ({
|
|
118
122
|
routes: [
|
|
@@ -132,12 +136,26 @@ describe('Test EditSubUnit', () => {
|
|
|
132
136
|
await alertAction.props.rightButtonClick();
|
|
133
137
|
});
|
|
134
138
|
expect(alertAction.props.visible).toEqual(false);
|
|
139
|
+
expect(axios.delete).toHaveBeenCalledWith(
|
|
140
|
+
'https://backend.eoh.io/api/property_manager/1/sub_units/2/'
|
|
141
|
+
);
|
|
142
|
+
expect(Toast.show).toHaveBeenCalledWith({
|
|
143
|
+
type: 'success',
|
|
144
|
+
position: 'bottom',
|
|
145
|
+
text1: getTranslate('en', 'text_remove_sub_unit_success'),
|
|
146
|
+
visibilityTime: 1000,
|
|
147
|
+
});
|
|
148
|
+
expect(mockedPop).toHaveBeenCalledWith(2);
|
|
135
149
|
});
|
|
136
150
|
|
|
137
151
|
test('alertAction rightButtonClick success', async () => {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
152
|
+
const response = {
|
|
153
|
+
status: 200,
|
|
154
|
+
};
|
|
155
|
+
axios.delete.mockImplementation(async () => {
|
|
156
|
+
return response;
|
|
157
|
+
});
|
|
158
|
+
|
|
141
159
|
mockedDangerouslyGetState.mockImplementation(() => ({
|
|
142
160
|
routes: [{ name: 'route 1' }, { name: 'route 2' }, { name: 'route 3' }],
|
|
143
161
|
}));
|
|
@@ -150,13 +168,16 @@ describe('Test EditSubUnit', () => {
|
|
|
150
168
|
await act(async () => {
|
|
151
169
|
await alertAction.props.rightButtonClick();
|
|
152
170
|
});
|
|
153
|
-
expect(mockedPop).
|
|
171
|
+
expect(mockedPop).toHaveBeenCalledWith(3);
|
|
154
172
|
});
|
|
155
173
|
|
|
156
174
|
test('alertAction rightButtonClick fail', async () => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
const response = {
|
|
176
|
+
data: '',
|
|
177
|
+
};
|
|
178
|
+
axios.delete.mockImplementation(async () => {
|
|
179
|
+
return response;
|
|
180
|
+
});
|
|
160
181
|
|
|
161
182
|
mockedDangerouslyGetState.mockImplementation(() => ({
|
|
162
183
|
routes: [{ name: 'route 1' }, { name: 'route 2' }, { name: 'route 3' }],
|
|
@@ -229,9 +250,13 @@ describe('Test EditSubUnit', () => {
|
|
|
229
250
|
});
|
|
230
251
|
|
|
231
252
|
test('viewBottomButton onRightClick success', async () => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
253
|
+
const response = {
|
|
254
|
+
status: 200,
|
|
255
|
+
data: { name: 'Station name' },
|
|
256
|
+
};
|
|
257
|
+
axios.patch.mockImplementation(async () => {
|
|
258
|
+
return response;
|
|
259
|
+
});
|
|
235
260
|
|
|
236
261
|
act(() => {
|
|
237
262
|
tree = create(wrapComponent(route));
|
|
@@ -247,11 +272,29 @@ describe('Test EditSubUnit', () => {
|
|
|
247
272
|
await act(async () => {
|
|
248
273
|
await viewBottomButton.props.onRightClick();
|
|
249
274
|
});
|
|
275
|
+
|
|
276
|
+
expect(axios.patch).toHaveBeenCalledWith(
|
|
277
|
+
API.SUB_UNIT.MANAGE_SUB_UNIT(1, 2),
|
|
278
|
+
{ name: 'Station name' },
|
|
279
|
+
{}
|
|
280
|
+
);
|
|
281
|
+
expect(Toast.show).toHaveBeenCalledWith({
|
|
282
|
+
type: 'success',
|
|
283
|
+
position: 'bottom',
|
|
284
|
+
text1: getTranslate('en', 'text_rename_sub_unit_success'),
|
|
285
|
+
visibilityTime: 1000,
|
|
286
|
+
});
|
|
250
287
|
expect(text.props.children).toEqual('Station name');
|
|
251
288
|
});
|
|
252
289
|
|
|
253
290
|
test('viewBottomButton onRightClick fail', async () => {
|
|
254
|
-
|
|
291
|
+
const response = {
|
|
292
|
+
data: '',
|
|
293
|
+
};
|
|
294
|
+
axios.patch.mockImplementation(async () => {
|
|
295
|
+
return response;
|
|
296
|
+
});
|
|
297
|
+
|
|
255
298
|
await act(async () => {
|
|
256
299
|
tree = create(wrapComponent(route));
|
|
257
300
|
});
|
|
@@ -262,6 +305,12 @@ describe('Test EditSubUnit', () => {
|
|
|
262
305
|
await act(async () => {
|
|
263
306
|
await viewBottomButton.props.onRightClick();
|
|
264
307
|
});
|
|
308
|
+
|
|
309
|
+
expect(axios.patch).toHaveBeenCalledWith(
|
|
310
|
+
API.SUB_UNIT.MANAGE_SUB_UNIT(1, 2),
|
|
311
|
+
{ name: 'Station name' },
|
|
312
|
+
{}
|
|
313
|
+
);
|
|
265
314
|
expect(mockedDispatch).not.toHaveBeenCalled();
|
|
266
315
|
expect(Toast.show).not.toHaveBeenCalled();
|
|
267
316
|
});
|
|
@@ -317,9 +366,13 @@ describe('Test EditSubUnit', () => {
|
|
|
317
366
|
});
|
|
318
367
|
|
|
319
368
|
test('setImage and updateBackground success', async () => {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
369
|
+
const response = {
|
|
370
|
+
status: 200,
|
|
371
|
+
data: { name: 'Station name' },
|
|
372
|
+
};
|
|
373
|
+
axios.patch.mockImplementation(async () => {
|
|
374
|
+
return response;
|
|
375
|
+
});
|
|
323
376
|
|
|
324
377
|
act(() => {
|
|
325
378
|
tree = create(wrapComponent(route));
|
|
@@ -336,10 +389,23 @@ describe('Test EditSubUnit', () => {
|
|
|
336
389
|
expect(image.props.source).toEqual({
|
|
337
390
|
uri: 'path',
|
|
338
391
|
});
|
|
392
|
+
expect(axios.patch).toHaveBeenCalled();
|
|
393
|
+
expect(Toast.show).toHaveBeenCalledWith({
|
|
394
|
+
type: 'success',
|
|
395
|
+
position: 'bottom',
|
|
396
|
+
text1: getTranslate('en', 'text_change_background_sub_unit_success'),
|
|
397
|
+
visibilityTime: 1000,
|
|
398
|
+
});
|
|
339
399
|
});
|
|
340
400
|
|
|
341
401
|
test('setImage and updateBackground but fail', async () => {
|
|
342
|
-
|
|
402
|
+
const response = {
|
|
403
|
+
data: '',
|
|
404
|
+
};
|
|
405
|
+
axios.patch.mockImplementation(async () => {
|
|
406
|
+
return response;
|
|
407
|
+
});
|
|
408
|
+
|
|
343
409
|
act(() => {
|
|
344
410
|
tree = create(wrapComponent(route));
|
|
345
411
|
});
|
|
@@ -355,5 +421,7 @@ describe('Test EditSubUnit', () => {
|
|
|
355
421
|
expect(image.props.source).toEqual({
|
|
356
422
|
uri: 'path',
|
|
357
423
|
});
|
|
424
|
+
expect(axios.patch).toHaveBeenCalled();
|
|
425
|
+
expect(Toast.show).not.toHaveBeenCalled();
|
|
358
426
|
});
|
|
359
427
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { ScrollView
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
3
|
import { create } from 'react-test-renderer';
|
|
4
4
|
import { act } from '@testing-library/react-hooks';
|
|
5
5
|
import ManageSubUnit from '../ManageSubUnit';
|
|
@@ -7,7 +7,6 @@ import { SCProvider } from '../../../context';
|
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
import { RowItem } from '../../../commons/RowItem';
|
|
9
9
|
import Routes from '../../../utils/Route';
|
|
10
|
-
import { TESTID } from '../../../configs/Constants';
|
|
11
10
|
|
|
12
11
|
const mockSetState = jest.fn();
|
|
13
12
|
|
|
@@ -77,29 +76,4 @@ describe('Test ManageSubUnit', () => {
|
|
|
77
76
|
screen: 'EditSubUnit',
|
|
78
77
|
});
|
|
79
78
|
});
|
|
80
|
-
it('ManageSubUnit add sub unit', async () => {
|
|
81
|
-
let route = {
|
|
82
|
-
params: { unit: { id: 1, name: 'unit 1' } },
|
|
83
|
-
};
|
|
84
|
-
await act(() => {
|
|
85
|
-
tree = create(wrapComponent(route));
|
|
86
|
-
});
|
|
87
|
-
const instance = tree.root;
|
|
88
|
-
const buttonAddSubUnit = instance.find(
|
|
89
|
-
(el) =>
|
|
90
|
-
el.props.testID === TESTID.ADD_SUB_UNIT && el.type === TouchableOpacity
|
|
91
|
-
);
|
|
92
|
-
act(() => {
|
|
93
|
-
buttonAddSubUnit.props.onPress();
|
|
94
|
-
});
|
|
95
|
-
expect(mockedNavigate).toHaveBeenCalledWith(Routes.AddSubUnitStack, {
|
|
96
|
-
params: {
|
|
97
|
-
unit: {
|
|
98
|
-
id: 1,
|
|
99
|
-
name: 'unit 1',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
screen: Routes.AddSubUnit,
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
79
|
});
|