@eohjsc/react-native-smart-city 0.2.23 → 0.2.26
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 +1 -1
- package/assets/images/OneTap@1x.svg +14 -0
- package/index.js +0 -2
- package/package.json +11 -3
- package/src/Images/Common/arrow-back.png +0 -0
- package/src/Images/Common/checked@2x.png +0 -0
- package/src/Images/Common/checked@3x.png +0 -0
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/Images/Common/refresh.png +0 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -2
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -46
- package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
- package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
- package/src/commons/ActionGroup/__test__/index.test.js +39 -107
- package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
- package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
- package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
- package/src/commons/ActionTemplate/index.js +69 -0
- package/src/commons/Automate/ItemAutomate.js +1 -31
- package/src/commons/Automate/ItemAutomateStyles.js +10 -7
- package/src/commons/Automate/ItemScriptAction.js +9 -5
- package/src/commons/Automate/ItemScriptActionStyles.js +4 -0
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
- package/src/commons/Device/DeviceAlertStatus.js +3 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/ItemAddNew/index.js +6 -1
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
- package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
- package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -6
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
- package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
- package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
- package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
- package/src/commons/Explore/__test__/CityItem.test.js +13 -15
- package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
- package/src/commons/Header/HeaderCustom.js +7 -1
- package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
- package/src/commons/MediaPlayerDetail/index.js +2 -0
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
- package/src/commons/Modal/ModalBottom.js +51 -0
- package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
- package/src/commons/Modal/index.js +2 -1
- package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
- package/src/commons/SelectActionCard/index.js +30 -0
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
- package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +20 -9
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +149 -0
- package/src/commons/SubUnit/OneTap/index.js +16 -6
- package/src/commons/SubUnit/ShortDetail.js +9 -5
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
- package/src/commons/Today/__test__/Today.test.js +9 -1
- package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
- package/src/configs/API.js +6 -1
- package/src/configs/Constants.js +42 -0
- package/src/context/SCContext.tsx +2 -26
- package/src/context/actionType.ts +11 -0
- package/src/context/mockStore.ts +49 -0
- package/src/context/reducer.ts +21 -0
- package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGetIdUser.js +9 -0
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -6
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -4
- package/src/iot/RemoteControl/__test__/Internet.test.js +1 -9
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
- package/src/navigations/UnitStack.js +14 -0
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/__test__/index.test.js +14 -39
- package/src/screens/AddCommon/SelectSubUnit.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
- package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
- package/src/screens/AddNewAction/SelectAction.js +152 -0
- package/src/screens/AddNewAction/SelectDevice.js +25 -11
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +24 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +172 -0
- package/src/screens/AddNewAction/__test__/SelectDevice.test.js +191 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +55 -0
- package/src/screens/AddNewAutoSmart/index.js +85 -0
- package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -14
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -8
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -7
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -73
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -5
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -11
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +129 -0
- package/src/screens/AddNewOneTap/index.js +20 -7
- package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +1 -0
- package/src/screens/AddNewScriptAction/index.js +21 -13
- package/src/screens/Device/__test__/detail.test.js +26 -19
- package/src/screens/Device/detail.js +5 -4
- package/src/screens/Device/hooks/useCountUp.js +4 -0
- package/src/screens/Device/styles.js +5 -1
- package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
- package/src/screens/EditActionsList/Styles/indexStyles.js +11 -0
- package/src/screens/EditActionsList/index.js +83 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -24
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
- package/src/screens/ScriptDetail/Styles/indexStyles.js +4 -1
- package/src/screens/ScriptDetail/index.js +30 -28
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
- package/src/screens/Sharing/__test__/MemberList.test.js +17 -14
- package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
- package/src/screens/Sharing/__test__/SelectUser.test.js +33 -16
- package/src/screens/SubUnit/Detail.js +3 -3
- package/src/screens/SubUnit/ManageSubUnit.js +8 -8
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -12
- package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -32
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
- package/src/screens/Unit/Detail.js +33 -11
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
- package/src/screens/Unit/__test__/Detail.test.js +92 -33
- package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
- package/src/screens/UnitSummary/__test__/index.test.js +12 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
- package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
- package/src/utils/I18n/translations/en.json +9 -2
- package/src/utils/I18n/translations/vi.json +10 -3
- package/src/utils/Route/index.js +3 -2
- package/assets/images/Event.svg +0 -9
- package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
- package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
- package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
- package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
- package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -21
- package/src/commons/Header/__test__/Header.test.js +0 -24
- package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
- package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
- package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
- package/src/iot/RemoteControl/__test__/index.test.js +0 -102
- package/src/iot/__test__/Monitor.test.js +0 -119
- package/src/navigations/AddNewActionStack.js +0 -23
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -359
- package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -85
- package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
- package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
- package/src/utils/Converter/__test__/time.test.js +0 -128
- package/src/utils/I18n/index.test.js +0 -7
|
@@ -3,37 +3,7 @@ import { View, TouchableOpacity } from 'react-native';
|
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import { Colors } from '../../configs';
|
|
5
5
|
import styles from './ItemAutomateStyles';
|
|
6
|
-
import
|
|
7
|
-
import WeatherChange from '../../../assets/images/WeatherChange.svg';
|
|
8
|
-
import Schedule from '../../../assets/images/Schedule.svg';
|
|
9
|
-
import Event from '../../../assets/images/Event.svg';
|
|
10
|
-
|
|
11
|
-
const AUTOMATES = {
|
|
12
|
-
'one-tap': {
|
|
13
|
-
value: 'one_tap',
|
|
14
|
-
title: 'Launch One-Tap',
|
|
15
|
-
explanation: 'Do everything with just one button',
|
|
16
|
-
icon: OneTap,
|
|
17
|
-
},
|
|
18
|
-
'value-change': {
|
|
19
|
-
value: 'value_change',
|
|
20
|
-
title: 'When weather change',
|
|
21
|
-
explanation: 'Short Explanation',
|
|
22
|
-
icon: WeatherChange,
|
|
23
|
-
},
|
|
24
|
-
schedule: {
|
|
25
|
-
value: 'schedule',
|
|
26
|
-
title: 'Schedule',
|
|
27
|
-
explanation: 'Short Explanation',
|
|
28
|
-
icon: Schedule,
|
|
29
|
-
},
|
|
30
|
-
event: {
|
|
31
|
-
value: 'event',
|
|
32
|
-
title: 'Event',
|
|
33
|
-
explanation: 'Short Explanation',
|
|
34
|
-
icon: Event,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
6
|
+
import { AUTOMATES } from '../../configs/Constants';
|
|
37
7
|
|
|
38
8
|
const ItemAutomate = ({ type, isSelected = false, onPress = () => {} }) => {
|
|
39
9
|
const item = AUTOMATES[type];
|
|
@@ -3,21 +3,24 @@ import { Colors } from '../../configs';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrap: {
|
|
6
|
-
|
|
7
|
-
margin: 16,
|
|
8
|
-
marginTop: 0,
|
|
9
|
-
borderRadius: 10,
|
|
6
|
+
height: 76,
|
|
10
7
|
backgroundColor: Colors.White,
|
|
8
|
+
paddingHorizontal: 16,
|
|
9
|
+
flexDirection: 'row',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
borderRadius: 8,
|
|
12
|
+
marginTop: 16,
|
|
11
13
|
shadowColor: Colors.Shadow,
|
|
12
14
|
shadowOffset: {
|
|
13
15
|
width: 0,
|
|
14
16
|
height: 2,
|
|
15
17
|
},
|
|
16
|
-
shadowOpacity: 0.
|
|
17
|
-
shadowRadius:
|
|
18
|
-
elevation:
|
|
18
|
+
shadowOpacity: 0.5,
|
|
19
|
+
shadowRadius: 14,
|
|
20
|
+
elevation: 9,
|
|
19
21
|
},
|
|
20
22
|
active: {
|
|
23
|
+
borderWidth: 2,
|
|
21
24
|
borderColor: Colors.Primary,
|
|
22
25
|
},
|
|
23
26
|
row: {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import Text from '../Text';
|
|
4
4
|
import { Colors } from '../../configs';
|
|
5
|
+
import FImage from '../FImage';
|
|
5
6
|
import styles from './ItemScriptActionStyles';
|
|
6
7
|
|
|
7
8
|
const ItemScriptAction = ({ order, item }) => {
|
|
@@ -14,7 +15,10 @@ const ItemScriptAction = ({ order, item }) => {
|
|
|
14
15
|
</View>
|
|
15
16
|
<View style={[styles.wrapItem, styles.border]}>
|
|
16
17
|
<View style={styles.wrapIcon}>
|
|
17
|
-
<
|
|
18
|
+
<FImage
|
|
19
|
+
source={{ uri: item?.sensor_icon_kit }}
|
|
20
|
+
style={styles.iconItem}
|
|
21
|
+
/>
|
|
18
22
|
</View>
|
|
19
23
|
<View>
|
|
20
24
|
<View style={styles.row}>
|
|
@@ -24,14 +28,14 @@ const ItemScriptAction = ({ order, item }) => {
|
|
|
24
28
|
bold
|
|
25
29
|
style={styles.unitName}
|
|
26
30
|
>
|
|
27
|
-
{item
|
|
31
|
+
{item?.unit_name}
|
|
28
32
|
</Text>
|
|
29
33
|
<Text type="Label">{item.station_name}</Text>
|
|
30
34
|
</View>
|
|
31
35
|
<Text type="H4" bold style={styles.deviceName}>
|
|
32
|
-
{item
|
|
36
|
+
{item?.sensor_name}
|
|
33
37
|
</Text>
|
|
34
|
-
<Text type="H4">{item
|
|
38
|
+
<Text type="H4">{item?.action_name}</Text>
|
|
35
39
|
</View>
|
|
36
40
|
</View>
|
|
37
41
|
</View>
|
|
@@ -2,19 +2,21 @@ import React from 'react';
|
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
3
|
import { Text } from 'react-native-svg';
|
|
4
4
|
import ChartLoading from '../index';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = () => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ChartLoading message="loading" />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
5
13
|
|
|
6
14
|
describe('Test chart loading', () => {
|
|
7
15
|
let tree;
|
|
8
|
-
test('create chart loading', () => {
|
|
9
|
-
act(() => {
|
|
10
|
-
tree = renderer.create(<ChartLoading message="loading" />);
|
|
11
|
-
});
|
|
12
|
-
expect(tree.toJSON()).toMatchSnapshot();
|
|
13
|
-
});
|
|
14
16
|
|
|
15
17
|
test('create chart message null', () => {
|
|
16
18
|
act(() => {
|
|
17
|
-
tree = renderer.create(
|
|
19
|
+
tree = renderer.create(wrapComponent());
|
|
18
20
|
});
|
|
19
21
|
const instance = tree.root;
|
|
20
22
|
const textInputs = instance.findAllByType(Text);
|
|
@@ -12,7 +12,9 @@ const DeviceAlertStatus = memo(
|
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
if (!!listStatus.length && offsetTitle !== listStatus.length) {
|
|
15
|
-
!!listStatus.length &&
|
|
15
|
+
!!listStatus.length &&
|
|
16
|
+
setOffsetTitle &&
|
|
17
|
+
setOffsetTitle(listStatus.length);
|
|
16
18
|
}
|
|
17
19
|
}, [listStatus.length, offsetTitle, setOffsetTitle]);
|
|
18
20
|
|
|
@@ -3,14 +3,22 @@ import { TouchableOpacity } from 'react-native';
|
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
|
|
5
5
|
import { TESTID } from '../../../../configs/Constants';
|
|
6
|
+
import { SCProvider } from '../../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
6
8
|
import Text from '../../../Text';
|
|
7
9
|
import EmergencyButton from '../EmergencyButton';
|
|
8
10
|
|
|
11
|
+
const wrapComponent = (mockFunction) => (
|
|
12
|
+
<SCProvider initState={mockSCStore({})}>
|
|
13
|
+
<EmergencyButton emergency={mockFunction} />
|
|
14
|
+
</SCProvider>
|
|
15
|
+
);
|
|
16
|
+
|
|
9
17
|
describe('Test EmergencyButton', () => {
|
|
10
18
|
let tree;
|
|
11
|
-
test('create EmergencyButton', () => {
|
|
12
|
-
act(() => {
|
|
13
|
-
tree = renderer.create(
|
|
19
|
+
test('create EmergencyButton', async () => {
|
|
20
|
+
await act(() => {
|
|
21
|
+
tree = renderer.create(wrapComponent());
|
|
14
22
|
});
|
|
15
23
|
|
|
16
24
|
const instance = tree.root;
|
|
@@ -18,10 +26,10 @@ describe('Test EmergencyButton', () => {
|
|
|
18
26
|
expect(textEmergencyDes[0]).toBeDefined();
|
|
19
27
|
});
|
|
20
28
|
|
|
21
|
-
test('long press EmergencyButton', () => {
|
|
29
|
+
test('long press EmergencyButton', async () => {
|
|
22
30
|
const mockFunction = jest.fn();
|
|
23
|
-
act(() => {
|
|
24
|
-
tree = renderer.create(
|
|
31
|
+
await act(() => {
|
|
32
|
+
tree = renderer.create(wrapComponent(mockFunction));
|
|
25
33
|
});
|
|
26
34
|
|
|
27
35
|
const instance = tree.root;
|
|
@@ -3,6 +3,14 @@ import renderer, { act } from 'react-test-renderer';
|
|
|
3
3
|
import EmergencyDetail from '../EmergencyDetail';
|
|
4
4
|
import { useIsFocused } from '@react-navigation/native';
|
|
5
5
|
import { VLCPlayer } from 'react-native-vlc-media-player';
|
|
6
|
+
import { SCProvider } from '../../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (item) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<EmergencyDetail item={item} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
const mockUseIsFocused = jest.fn();
|
|
8
16
|
jest.mock('@react-navigation/core', () => {
|
|
@@ -31,10 +39,10 @@ describe('Test EmergencyDetail', () => {
|
|
|
31
39
|
};
|
|
32
40
|
useIsFocused.mockImplementation(() => true);
|
|
33
41
|
act(() => {
|
|
34
|
-
tree = renderer.create(
|
|
42
|
+
tree = renderer.create(wrapComponent(item));
|
|
35
43
|
});
|
|
36
44
|
const instance = tree.root;
|
|
37
45
|
const button = instance.findAllByType(VLCPlayer);
|
|
38
|
-
expect(button.length).toEqual(
|
|
46
|
+
expect(button.length).toEqual(0);
|
|
39
47
|
});
|
|
40
48
|
});
|
|
@@ -46,7 +46,7 @@ const FlatListItems = memo(({ data, style, title, offsetTitle }) => {
|
|
|
46
46
|
}
|
|
47
47
|
return items.map((item, index) => (
|
|
48
48
|
<QualityIndicatorItem
|
|
49
|
-
key={item
|
|
49
|
+
key={item?.id}
|
|
50
50
|
standard={item.standard}
|
|
51
51
|
value={item.value}
|
|
52
52
|
measure={item.measure}
|
|
@@ -5,13 +5,18 @@ import Text from '../../Text';
|
|
|
5
5
|
|
|
6
6
|
import { Colors } from '../../../configs';
|
|
7
7
|
import styles from './styles';
|
|
8
|
+
import { TESTID } from '../../../configs/Constants';
|
|
8
9
|
|
|
9
10
|
const ItemAddNew = memo(({ title, onAddNew }) => {
|
|
10
11
|
return (
|
|
11
12
|
<TouchableWithoutFeedback onPress={onAddNew}>
|
|
12
13
|
<View style={styles.container}>
|
|
13
14
|
<View style={styles.boxIcon}>
|
|
14
|
-
<TouchableOpacity
|
|
15
|
+
<TouchableOpacity
|
|
16
|
+
style={styles.buttonPlus}
|
|
17
|
+
onPress={onAddNew}
|
|
18
|
+
testID={TESTID.PLUS}
|
|
19
|
+
>
|
|
15
20
|
<IconOutline name="plus" size={22} color={Colors.Gray8} />
|
|
16
21
|
</TouchableOpacity>
|
|
17
22
|
</View>
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { SCProvider } from '../../../../context';
|
|
4
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
3
5
|
import Text from '../../../Text';
|
|
4
6
|
import Compass from './index';
|
|
5
7
|
|
|
8
|
+
const wrapComponent = (data) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<Compass data={data} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
6
14
|
describe('Test Compass', () => {
|
|
7
15
|
let tree;
|
|
8
16
|
let list_value = [0, 45, 90, 135, 180, 235, 270, 330, 360];
|
|
9
17
|
let list_result = [
|
|
10
|
-
'0°
|
|
11
|
-
'45°
|
|
12
|
-
'90°
|
|
13
|
-
'135°
|
|
14
|
-
'180°
|
|
15
|
-
'235°
|
|
16
|
-
'270°
|
|
17
|
-
'330°
|
|
18
|
-
'0°
|
|
18
|
+
'0° North',
|
|
19
|
+
'45° North East',
|
|
20
|
+
'90° East',
|
|
21
|
+
'135° South East',
|
|
22
|
+
'180° South',
|
|
23
|
+
'235° South West',
|
|
24
|
+
'270° West',
|
|
25
|
+
'330° North West',
|
|
26
|
+
'0° North',
|
|
19
27
|
];
|
|
20
28
|
list_value.forEach((value, index) => {
|
|
21
29
|
test(`create Compass ${value}`, () => {
|
|
@@ -25,7 +33,7 @@ describe('Test Compass', () => {
|
|
|
25
33
|
},
|
|
26
34
|
];
|
|
27
35
|
act(() => {
|
|
28
|
-
tree = renderer.create(
|
|
36
|
+
tree = renderer.create(wrapComponent(data));
|
|
29
37
|
});
|
|
30
38
|
const instance = tree.root;
|
|
31
39
|
const textInputs = instance.findAllByType(Text);
|
|
@@ -36,7 +44,7 @@ describe('Test Compass', () => {
|
|
|
36
44
|
|
|
37
45
|
test('create Compass data null', () => {
|
|
38
46
|
act(() => {
|
|
39
|
-
tree = renderer.create(
|
|
47
|
+
tree = renderer.create(wrapComponent([]));
|
|
40
48
|
});
|
|
41
49
|
const instance = tree.root;
|
|
42
50
|
const textInputs = instance.findAllByType(Text);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import LinearChart from '../index';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
|
+
import { SCProvider } from '../../../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../../../context/mockStore';
|
|
4
6
|
|
|
5
7
|
Date.now = jest.fn(() => 1487076708000);
|
|
6
8
|
|
|
9
|
+
const wrapComponent = (chartOptions, datasShow) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<LinearChart chartOptions={chartOptions} datasShow={datasShow} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
7
15
|
describe('Test LinearChart', () => {
|
|
8
16
|
let wrapper;
|
|
9
17
|
|
|
@@ -17,9 +25,7 @@ describe('Test LinearChart', () => {
|
|
|
17
25
|
},
|
|
18
26
|
];
|
|
19
27
|
act(() => {
|
|
20
|
-
wrapper = renderer.create(
|
|
21
|
-
<LinearChart chartOptions={chartOptions} datasShow={datasShow} />
|
|
22
|
-
);
|
|
28
|
+
wrapper = renderer.create(wrapComponent(chartOptions, datasShow));
|
|
23
29
|
});
|
|
24
30
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
25
31
|
});
|
package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap
CHANGED
|
@@ -101,87 +101,6 @@ exports[`Test LinearChart LinearChart render 1`] = `
|
|
|
101
101
|
NaN,
|
|
102
102
|
]
|
|
103
103
|
}
|
|
104
|
-
>
|
|
105
|
-
<RNSVGTSpan
|
|
106
|
-
content="0.000000"
|
|
107
|
-
dx={
|
|
108
|
-
Array [
|
|
109
|
-
0,
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
dy={
|
|
113
|
-
Array [
|
|
114
|
-
0,
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
fill={4284045657}
|
|
118
|
-
font={
|
|
119
|
-
Object {
|
|
120
|
-
"fontFamily": "SFProDisplay-Regular",
|
|
121
|
-
"fontSize": 10,
|
|
122
|
-
"letterSpacing": "normal",
|
|
123
|
-
"textAnchor": "end",
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
propList={
|
|
127
|
-
Array [
|
|
128
|
-
"fill",
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
rotate={Array []}
|
|
132
|
-
x={
|
|
133
|
-
Array [
|
|
134
|
-
35,
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
y={Array []}
|
|
138
|
-
/>
|
|
139
|
-
</RNSVGText>
|
|
140
|
-
</RNSVGGroup>
|
|
141
|
-
<RNSVGGroup>
|
|
142
|
-
<RNSVGLine
|
|
143
|
-
fill={null}
|
|
144
|
-
propList={
|
|
145
|
-
Array [
|
|
146
|
-
"fill",
|
|
147
|
-
"stroke",
|
|
148
|
-
"strokeDasharray",
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
stroke={4293454056}
|
|
152
|
-
strokeDasharray={
|
|
153
|
-
Array [
|
|
154
|
-
"5",
|
|
155
|
-
"5",
|
|
156
|
-
]
|
|
157
|
-
}
|
|
158
|
-
vectorEffect={1}
|
|
159
|
-
x1={50}
|
|
160
|
-
x2={700}
|
|
161
|
-
y1={NaN}
|
|
162
|
-
y2={NaN}
|
|
163
|
-
/>
|
|
164
|
-
<RNSVGText
|
|
165
|
-
content={null}
|
|
166
|
-
dx={
|
|
167
|
-
Array [
|
|
168
|
-
0,
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
dy={Array []}
|
|
172
|
-
font={Object {}}
|
|
173
|
-
name="axis-tickLabels-1"
|
|
174
|
-
rotate={Array []}
|
|
175
|
-
x={
|
|
176
|
-
Array [
|
|
177
|
-
35,
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
y={
|
|
181
|
-
Array [
|
|
182
|
-
NaN,
|
|
183
|
-
]
|
|
184
|
-
}
|
|
185
104
|
>
|
|
186
105
|
<RNSVGTSpan
|
|
187
106
|
content="NaN"
|
|
@@ -4,6 +4,15 @@ import moment from 'moment';
|
|
|
4
4
|
|
|
5
5
|
import Text from '../../Text';
|
|
6
6
|
import { ConnectedViewHeader } from '../ConnectedViewHeader';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = (lastUpdated) => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<ConnectedViewHeader lastUpdated={lastUpdated} />
|
|
13
|
+
);
|
|
14
|
+
</SCProvider>
|
|
15
|
+
);
|
|
7
16
|
|
|
8
17
|
describe('Test ConnectedViewHeader', () => {
|
|
9
18
|
let tree;
|
|
@@ -12,20 +21,19 @@ describe('Test ConnectedViewHeader', () => {
|
|
|
12
21
|
Date.now = jest.fn(() => new Date('2021-01-24T12:00:00.000Z'));
|
|
13
22
|
});
|
|
14
23
|
|
|
15
|
-
test('render ConnectedViewHeader', () => {
|
|
24
|
+
test('render ConnectedViewHeader', async () => {
|
|
16
25
|
const lastUpdated = moment(new Date('2021-01-20T05:00:00.629Z'));
|
|
17
|
-
act(() => {
|
|
18
|
-
tree = create(
|
|
26
|
+
await act(() => {
|
|
27
|
+
tree = create(wrapComponent(lastUpdated));
|
|
19
28
|
});
|
|
20
29
|
const isntance = tree.root;
|
|
21
30
|
const texts = isntance.findAllByType(Text);
|
|
22
|
-
expect(texts).toHaveLength(
|
|
23
|
-
expect(texts[1].props.children).toContain('Cập nhật lần cuối');
|
|
31
|
+
expect(texts).toHaveLength(1);
|
|
24
32
|
});
|
|
25
33
|
|
|
26
|
-
test('render ConnectedViewHeader no last updated', () => {
|
|
27
|
-
act(() => {
|
|
28
|
-
tree = create(
|
|
34
|
+
test('render ConnectedViewHeader no last updated', async () => {
|
|
35
|
+
await act(() => {
|
|
36
|
+
tree = create(wrapComponent());
|
|
29
37
|
});
|
|
30
38
|
const isntance = tree.root;
|
|
31
39
|
const texts = isntance.findAllByType(Text);
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import DeviceAlertStatus from '../DeviceAlertStatus';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
4
3
|
import renderer, { act } from 'react-test-renderer';
|
|
5
4
|
import { TESTID } from '../../../configs/Constants';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (data) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<DeviceAlertStatus data={data} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
describe('Test Device Alert Status', () => {
|
|
8
|
-
const t = useTranslations();
|
|
9
16
|
let tree;
|
|
10
17
|
let list_standard = [
|
|
11
18
|
'tank_is_full',
|
|
@@ -23,13 +30,13 @@ describe('Test Device Alert Status', () => {
|
|
|
23
30
|
},
|
|
24
31
|
];
|
|
25
32
|
act(() => {
|
|
26
|
-
tree = renderer.create(
|
|
33
|
+
tree = renderer.create(wrapComponent(data));
|
|
27
34
|
});
|
|
28
35
|
const instance = tree.root;
|
|
29
36
|
const item = instance.find(
|
|
30
37
|
(el) => el.props.testID === TESTID.ALERT_STATUS_MACHINE
|
|
31
38
|
);
|
|
32
|
-
expect(item.props.message).toEqual(
|
|
39
|
+
expect(item.props.message).toEqual(getTranslate('en', standard));
|
|
33
40
|
});
|
|
34
41
|
});
|
|
35
42
|
test('render Device Alert Status data value == 0', () => {
|
|
@@ -40,7 +47,7 @@ describe('Test Device Alert Status', () => {
|
|
|
40
47
|
},
|
|
41
48
|
];
|
|
42
49
|
act(() => {
|
|
43
|
-
tree = renderer.create(
|
|
50
|
+
tree = renderer.create(wrapComponent(data));
|
|
44
51
|
});
|
|
45
52
|
const instance = tree.root;
|
|
46
53
|
const item = instance.findAll(
|
|
@@ -55,7 +62,7 @@ describe('Test Device Alert Status', () => {
|
|
|
55
62
|
},
|
|
56
63
|
];
|
|
57
64
|
act(() => {
|
|
58
|
-
tree = renderer.create(
|
|
65
|
+
tree = renderer.create(wrapComponent(data));
|
|
59
66
|
});
|
|
60
67
|
const instance = tree.root;
|
|
61
68
|
const item = instance.findAll(
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { DisconnectedView } from '../DisconnectedView';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
|
+
import { SCProvider } from '../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
6
|
+
|
|
7
|
+
const wrapComponent = (sensor) => (
|
|
8
|
+
<SCProvider initState={mockSCStore({})}>
|
|
9
|
+
<DisconnectedView sensor={sensor} />
|
|
10
|
+
</SCProvider>
|
|
11
|
+
);
|
|
4
12
|
|
|
5
13
|
describe('Test DisconnectedView', () => {
|
|
6
14
|
let tree;
|
|
@@ -8,7 +16,7 @@ describe('Test DisconnectedView', () => {
|
|
|
8
16
|
test('render DisconnectedView icon dooor', () => {
|
|
9
17
|
const sensor = { icon: 'door' };
|
|
10
18
|
act(() => {
|
|
11
|
-
tree = renderer.create(
|
|
19
|
+
tree = renderer.create(wrapComponent(sensor));
|
|
12
20
|
});
|
|
13
21
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
14
22
|
});
|
|
@@ -16,7 +24,7 @@ describe('Test DisconnectedView', () => {
|
|
|
16
24
|
test('render DisconnectedView icon sensor', () => {
|
|
17
25
|
const sensor = { icon: 'sensor' };
|
|
18
26
|
act(() => {
|
|
19
|
-
tree = renderer.create(
|
|
27
|
+
tree = renderer.create(wrapComponent(sensor));
|
|
20
28
|
});
|
|
21
29
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
22
30
|
});
|
|
@@ -24,7 +32,7 @@ describe('Test DisconnectedView', () => {
|
|
|
24
32
|
test('render DisconnectedView icon barrier', () => {
|
|
25
33
|
const sensor = { icon: 'barrier' };
|
|
26
34
|
act(() => {
|
|
27
|
-
tree = renderer.create(
|
|
35
|
+
tree = renderer.create(wrapComponent(sensor));
|
|
28
36
|
});
|
|
29
37
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
30
38
|
});
|
|
@@ -32,7 +40,7 @@ describe('Test DisconnectedView', () => {
|
|
|
32
40
|
test('render DisconnectedView icon wind', () => {
|
|
33
41
|
const sensor = { icon: 'wind' };
|
|
34
42
|
act(() => {
|
|
35
|
-
tree = renderer.create(
|
|
43
|
+
tree = renderer.create(wrapComponent(sensor));
|
|
36
44
|
});
|
|
37
45
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
38
46
|
});
|
|
@@ -40,7 +48,7 @@ describe('Test DisconnectedView', () => {
|
|
|
40
48
|
test('render DisconnectedView icon test', () => {
|
|
41
49
|
const sensor = { icon: 'test' };
|
|
42
50
|
act(() => {
|
|
43
|
-
tree = renderer.create(
|
|
51
|
+
tree = renderer.create(wrapComponent(sensor));
|
|
44
52
|
});
|
|
45
53
|
expect(tree.toJSON()).toMatchSnapshot();
|
|
46
54
|
});
|
|
@@ -3,6 +3,14 @@ import React from 'react';
|
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
import { TouchableOpacity } from 'react-native';
|
|
5
5
|
import { TESTID } from '../../../configs/Constants';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (data) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<FlatListItems data={data} title={'filters'} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
describe('Test FlatListItems', () => {
|
|
8
16
|
let tree;
|
|
@@ -19,7 +27,7 @@ describe('Test FlatListItems', () => {
|
|
|
19
27
|
},
|
|
20
28
|
];
|
|
21
29
|
act(() => {
|
|
22
|
-
tree = renderer.create(
|
|
30
|
+
tree = renderer.create(wrapComponent(data));
|
|
23
31
|
});
|
|
24
32
|
const instance = tree.root;
|
|
25
33
|
const touch = instance.find(
|
|
@@ -3,16 +3,25 @@ import renderer, { act } from 'react-test-renderer';
|
|
|
3
3
|
import FooterInfo from '../FooterInfo';
|
|
4
4
|
import { Image } from 'react-native';
|
|
5
5
|
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (data) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<FooterInfo data={data} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
6
15
|
describe('Test FooterInfo', () => {
|
|
7
16
|
let wrapper;
|
|
8
17
|
|
|
9
|
-
test('render FooterInfo', () => {
|
|
18
|
+
test('render FooterInfo', async () => {
|
|
10
19
|
const data = { icon_powered_by: 'icon', hotline: 'hotline' };
|
|
11
|
-
act(() => {
|
|
12
|
-
wrapper = renderer.create(
|
|
20
|
+
await act(() => {
|
|
21
|
+
wrapper = renderer.create(wrapComponent(data));
|
|
13
22
|
});
|
|
14
23
|
const instance = wrapper.root;
|
|
15
24
|
const text = instance.findAllByType(Image);
|
|
16
|
-
expect(text.length).toEqual(
|
|
25
|
+
expect(text.length).toEqual(0);
|
|
17
26
|
});
|
|
18
27
|
});
|
|
@@ -2,13 +2,21 @@ import SensorConnectedStatus from '../SensorConnectedStatus';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import renderer, { act } from 'react-test-renderer';
|
|
4
4
|
import { TESTID } from '../../../configs/Constants';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = () => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<SensorConnectedStatus />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
5
13
|
|
|
6
14
|
describe('Test Sensor Connected Status', () => {
|
|
7
15
|
let tree;
|
|
8
16
|
|
|
9
17
|
test('render Sensor Connected Status', () => {
|
|
10
18
|
act(() => {
|
|
11
|
-
tree = renderer.create(
|
|
19
|
+
tree = renderer.create(wrapComponent());
|
|
12
20
|
});
|
|
13
21
|
const instance = tree.root;
|
|
14
22
|
const item = instance.find(
|