@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
|
@@ -2,12 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
|
|
5
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
5
|
import ConnectDevices from '../ConnectDevices';
|
|
7
6
|
import { TESTID } from '../../../configs/Constants';
|
|
8
7
|
import { TouchableOpacity } from 'react-native';
|
|
9
8
|
import _TextInput from '../../../commons/Form/TextInput';
|
|
10
9
|
import { AlertAction } from '../../../commons';
|
|
10
|
+
import { SCProvider } from '../../../context';
|
|
11
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
11
13
|
|
|
12
14
|
jest.mock('axios');
|
|
13
15
|
|
|
@@ -21,6 +23,12 @@ jest.mock('@react-navigation/native', () => {
|
|
|
21
23
|
};
|
|
22
24
|
});
|
|
23
25
|
|
|
26
|
+
const wrapComponent = (route) => (
|
|
27
|
+
<SCProvider initState={mockSCStore({})}>
|
|
28
|
+
<ConnectDevices route={route} />
|
|
29
|
+
</SCProvider>
|
|
30
|
+
);
|
|
31
|
+
|
|
24
32
|
describe('Test ConnectDevices', () => {
|
|
25
33
|
let tree;
|
|
26
34
|
let route;
|
|
@@ -49,9 +57,8 @@ describe('Test ConnectDevices', () => {
|
|
|
49
57
|
};
|
|
50
58
|
|
|
51
59
|
test('create', async () => {
|
|
52
|
-
const t = useTranslations();
|
|
53
60
|
await act(async () => {
|
|
54
|
-
tree = await create(
|
|
61
|
+
tree = await create(wrapComponent(route));
|
|
55
62
|
});
|
|
56
63
|
const instance = tree.root;
|
|
57
64
|
|
|
@@ -67,16 +74,20 @@ describe('Test ConnectDevices', () => {
|
|
|
67
74
|
);
|
|
68
75
|
const textDone = getText(instance, TESTID.CONNECTED_DEVICE_DONE);
|
|
69
76
|
|
|
70
|
-
expect(textSuccess.props.children).toEqual(
|
|
77
|
+
expect(textSuccess.props.children).toEqual(
|
|
78
|
+
getTranslate('en', 'successfully_connected')
|
|
79
|
+
);
|
|
71
80
|
expect(textUnitName.props.children).toEqual('Unit name');
|
|
72
81
|
expect(textDeviceName.props.children).toEqual('Sensor name');
|
|
73
|
-
expect(textRenameDevice.props.children).toEqual(
|
|
74
|
-
|
|
82
|
+
expect(textRenameDevice.props.children).toEqual(
|
|
83
|
+
getTranslate('en', 'rename_your_device')
|
|
84
|
+
);
|
|
85
|
+
expect(textDone.props.children).toEqual(getTranslate('en', 'done'));
|
|
75
86
|
});
|
|
76
87
|
|
|
77
88
|
test('hide show alert action', async () => {
|
|
78
89
|
await act(async () => {
|
|
79
|
-
tree = await create(
|
|
90
|
+
tree = await create(wrapComponent(route));
|
|
80
91
|
});
|
|
81
92
|
const instance = tree.root;
|
|
82
93
|
const button = instance.find(
|
|
@@ -98,7 +109,7 @@ describe('Test ConnectDevices', () => {
|
|
|
98
109
|
|
|
99
110
|
test('change and rename', async () => {
|
|
100
111
|
await act(async () => {
|
|
101
|
-
tree = await create(
|
|
112
|
+
tree = await create(wrapComponent(route));
|
|
102
113
|
});
|
|
103
114
|
const instance = tree.root;
|
|
104
115
|
const textDeviceName = getText(
|
|
@@ -5,8 +5,10 @@ import axios from 'axios';
|
|
|
5
5
|
import { API } from '../../../configs';
|
|
6
6
|
import ConnectingDevices from '../ConnectingDevices';
|
|
7
7
|
import Text from '../../../commons/Text';
|
|
8
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
9
8
|
import Routes from '../../../utils/Route';
|
|
9
|
+
import { SCProvider } from '../../../context';
|
|
10
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
11
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
10
12
|
|
|
11
13
|
jest.mock('axios');
|
|
12
14
|
|
|
@@ -20,8 +22,13 @@ jest.mock('@react-navigation/native', () => {
|
|
|
20
22
|
};
|
|
21
23
|
});
|
|
22
24
|
|
|
25
|
+
const wrapComponent = (route) => (
|
|
26
|
+
<SCProvider initState={mockSCStore({})}>
|
|
27
|
+
<ConnectingDevices route={route} />
|
|
28
|
+
</SCProvider>
|
|
29
|
+
);
|
|
30
|
+
|
|
23
31
|
describe('Test ConnectingDevices', () => {
|
|
24
|
-
const t = useTranslations();
|
|
25
32
|
let tree;
|
|
26
33
|
let route;
|
|
27
34
|
|
|
@@ -42,14 +49,16 @@ describe('Test ConnectingDevices', () => {
|
|
|
42
49
|
|
|
43
50
|
test('create', () => {
|
|
44
51
|
act(() => {
|
|
45
|
-
tree = create(
|
|
52
|
+
tree = create(wrapComponent(route));
|
|
46
53
|
});
|
|
47
54
|
const instance = tree.root;
|
|
48
55
|
const texts = instance.findAllByType(Text);
|
|
49
56
|
expect(texts).toHaveLength(2);
|
|
50
|
-
expect(texts[0].props.children).toEqual(
|
|
57
|
+
expect(texts[0].props.children).toEqual(
|
|
58
|
+
getTranslate('en', 'connecting_your_device')
|
|
59
|
+
);
|
|
51
60
|
expect(texts[1].props.children).toEqual(
|
|
52
|
-
|
|
61
|
+
getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
|
|
53
62
|
);
|
|
54
63
|
});
|
|
55
64
|
|
|
@@ -64,7 +73,7 @@ describe('Test ConnectingDevices', () => {
|
|
|
64
73
|
});
|
|
65
74
|
|
|
66
75
|
await act(async () => {
|
|
67
|
-
tree = await create(
|
|
76
|
+
tree = await create(wrapComponent(route));
|
|
68
77
|
});
|
|
69
78
|
await act(async () => {
|
|
70
79
|
await jest.runOnlyPendingTimers();
|
|
@@ -87,7 +96,7 @@ describe('Test ConnectingDevices', () => {
|
|
|
87
96
|
});
|
|
88
97
|
|
|
89
98
|
await act(async () => {
|
|
90
|
-
tree = await create(
|
|
99
|
+
tree = await create(wrapComponent(route));
|
|
91
100
|
});
|
|
92
101
|
await act(async () => {
|
|
93
102
|
await jest.runOnlyPendingTimers();
|
|
@@ -2,14 +2,20 @@ import React from 'react';
|
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
|
|
5
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
5
|
import AddNewGateway from '../index';
|
|
7
6
|
import GroupCheckBox from '../../../commons/GroupCheckBox';
|
|
8
7
|
import { TESTID } from '../../../configs/Constants';
|
|
9
|
-
import API from '../../../configs/API';
|
|
10
8
|
import { ViewButtonBottom } from '../../../commons';
|
|
11
|
-
import Routes from '../../../utils/Route';
|
|
12
9
|
import { TextInput } from 'react-native';
|
|
10
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
11
|
+
import { SCProvider } from '../../../context';
|
|
12
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (route) => (
|
|
15
|
+
<SCProvider initState={mockSCStore({})}>
|
|
16
|
+
<AddNewGateway route={route} />
|
|
17
|
+
</SCProvider>
|
|
18
|
+
);
|
|
13
19
|
|
|
14
20
|
jest.mock('axios');
|
|
15
21
|
|
|
@@ -31,7 +37,6 @@ jest.mock('@react-navigation/native', () => {
|
|
|
31
37
|
});
|
|
32
38
|
|
|
33
39
|
describe('Test AddNewGateway', () => {
|
|
34
|
-
const t = useTranslations();
|
|
35
40
|
let tree;
|
|
36
41
|
let route;
|
|
37
42
|
|
|
@@ -54,22 +59,25 @@ describe('Test AddNewGateway', () => {
|
|
|
54
59
|
|
|
55
60
|
test('create', async () => {
|
|
56
61
|
await act(async () => {
|
|
57
|
-
tree = await create(
|
|
62
|
+
tree = await create(wrapComponent(route));
|
|
58
63
|
});
|
|
59
64
|
const instance = tree.root;
|
|
60
65
|
const textAdd = getText(instance, TESTID.ADD_NEW_GATEWAY_ADD);
|
|
61
66
|
const textThen = getText(instance, TESTID.ADD_NEW_GATEWAY_THEN_SELECT);
|
|
62
|
-
expect(textAdd.props.children).toEqual(
|
|
63
|
-
|
|
67
|
+
expect(textAdd.props.children).toEqual(
|
|
68
|
+
getTranslate('en', 'add_new_gateway')
|
|
69
|
+
);
|
|
70
|
+
expect(textThen.props.children).toEqual(
|
|
71
|
+
getTranslate('en', 'please_add_your_phone_number_and_chip_name')
|
|
72
|
+
);
|
|
64
73
|
|
|
65
74
|
const groupCheckBox = instance.findAllByType(GroupCheckBox);
|
|
66
|
-
expect(groupCheckBox).toHaveLength(
|
|
67
|
-
expect(groupCheckBox[0].props.data).toEqual([]);
|
|
75
|
+
expect(groupCheckBox).toHaveLength(0);
|
|
68
76
|
});
|
|
69
77
|
|
|
70
78
|
test('onChange chipName and phoneNumber', async () => {
|
|
71
79
|
await act(async () => {
|
|
72
|
-
tree = await create(
|
|
80
|
+
tree = await create(wrapComponent(route));
|
|
73
81
|
});
|
|
74
82
|
const instance = tree.root;
|
|
75
83
|
const textInputs = instance.findAllByType(TextInput);
|
|
@@ -77,8 +85,12 @@ describe('Test AddNewGateway', () => {
|
|
|
77
85
|
expect(textInputs[0].props.value).toEqual('');
|
|
78
86
|
expect(textInputs[1].props.value).toEqual('');
|
|
79
87
|
|
|
80
|
-
expect(textInputs[0].props.placeholder).toEqual(
|
|
81
|
-
|
|
88
|
+
expect(textInputs[0].props.placeholder).toEqual(
|
|
89
|
+
getTranslate('en', 'phone_number_of_data_sim')
|
|
90
|
+
);
|
|
91
|
+
expect(textInputs[1].props.placeholder).toEqual(
|
|
92
|
+
getTranslate('en', 'gateway_name')
|
|
93
|
+
);
|
|
82
94
|
|
|
83
95
|
await act(async () => {
|
|
84
96
|
await textInputs[0].props.onChangeText('New phone number');
|
|
@@ -89,63 +101,24 @@ describe('Test AddNewGateway', () => {
|
|
|
89
101
|
expect(textInputs[1].props.value).toEqual('New chip name');
|
|
90
102
|
});
|
|
91
103
|
|
|
92
|
-
test('fetchDetails success', async () => {
|
|
93
|
-
const response = {
|
|
94
|
-
status: 200,
|
|
95
|
-
data: {
|
|
96
|
-
id: 1,
|
|
97
|
-
name: 'Unit name',
|
|
98
|
-
stations: [{ id: 2, name: 'Station name' }],
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
axios.get.mockImplementation(async () => {
|
|
102
|
-
return response;
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
await act(async () => {
|
|
106
|
-
tree = await create(<AddNewGateway route={route} />);
|
|
107
|
-
});
|
|
108
|
-
const instance = tree.root;
|
|
109
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
110
|
-
|
|
111
|
-
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
112
|
-
expect(groupCheckBox.props.data).toEqual([
|
|
113
|
-
{ id: 2, name: 'Station name', title: 'Station name' },
|
|
114
|
-
]);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('fetchDetails fail', async () => {
|
|
118
|
-
const response = {
|
|
119
|
-
data: {},
|
|
120
|
-
};
|
|
121
|
-
axios.get.mockImplementation(async () => {
|
|
122
|
-
return response;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
await act(async () => {
|
|
126
|
-
tree = await create(<AddNewGateway route={route} />);
|
|
127
|
-
});
|
|
128
|
-
const instance = tree.root;
|
|
129
|
-
expect(axios.get).toHaveBeenCalledWith(API.UNIT.UNIT_DETAIL(1), {});
|
|
130
|
-
|
|
131
|
-
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
132
|
-
expect(groupCheckBox.props.data).toEqual([]);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
104
|
test('ViewButtonBottom', async () => {
|
|
136
105
|
await act(async () => {
|
|
137
|
-
tree = await create(
|
|
106
|
+
tree = await create(wrapComponent(route));
|
|
138
107
|
});
|
|
139
108
|
const instance = tree.root;
|
|
140
109
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
141
110
|
|
|
142
|
-
expect(viewButtonBottom.props.leftTitle).toEqual(
|
|
143
|
-
|
|
111
|
+
expect(viewButtonBottom.props.leftTitle).toEqual(
|
|
112
|
+
getTranslate('en', 'text_back')
|
|
113
|
+
);
|
|
114
|
+
expect(viewButtonBottom.props.rightTitle).toEqual(
|
|
115
|
+
getTranslate('en', 'text_next')
|
|
116
|
+
);
|
|
144
117
|
});
|
|
145
118
|
|
|
146
119
|
test('ViewButtonBottom onLeftClick', async () => {
|
|
147
120
|
await act(async () => {
|
|
148
|
-
tree = await create(
|
|
121
|
+
tree = await create(wrapComponent(route));
|
|
149
122
|
});
|
|
150
123
|
const instance = tree.root;
|
|
151
124
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
@@ -157,7 +130,7 @@ describe('Test AddNewGateway', () => {
|
|
|
157
130
|
|
|
158
131
|
test('ViewButtonBottom onRightClick without select stationId', async () => {
|
|
159
132
|
await act(async () => {
|
|
160
|
-
tree = await create(
|
|
133
|
+
tree = await create(wrapComponent(route));
|
|
161
134
|
});
|
|
162
135
|
const instance = tree.root;
|
|
163
136
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
@@ -181,25 +154,14 @@ describe('Test AddNewGateway', () => {
|
|
|
181
154
|
});
|
|
182
155
|
|
|
183
156
|
await act(async () => {
|
|
184
|
-
tree = await create(
|
|
157
|
+
tree = await create(wrapComponent(route));
|
|
185
158
|
});
|
|
186
159
|
const instance = tree.root;
|
|
187
160
|
|
|
188
|
-
const groupCheckBox = instance.findByType(GroupCheckBox);
|
|
189
|
-
await act(async () => {
|
|
190
|
-
groupCheckBox.props.onSelect({ id: 2 }); // select stationId
|
|
191
|
-
});
|
|
192
|
-
|
|
193
161
|
const viewButtonBottom = instance.findByType(ViewButtonBottom);
|
|
194
162
|
await act(async () => {
|
|
195
163
|
viewButtonBottom.props.onRightClick();
|
|
196
164
|
});
|
|
197
|
-
expect(mockedNavigate).
|
|
198
|
-
chipName: '',
|
|
199
|
-
phoneNumber: '',
|
|
200
|
-
station_id: 2,
|
|
201
|
-
unit_id: 1,
|
|
202
|
-
unit_name: 'Unit name',
|
|
203
|
-
});
|
|
165
|
+
expect(mockedNavigate).not.toBeCalled();
|
|
204
166
|
});
|
|
205
167
|
});
|
|
@@ -2,9 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
|
|
5
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
5
|
import { TESTID } from '../../../configs/Constants';
|
|
7
6
|
import ConnectedGateway from '../ConnectedGateway';
|
|
7
|
+
import { SCProvider } from '../../../context';
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
8
10
|
|
|
9
11
|
jest.mock('axios');
|
|
10
12
|
|
|
@@ -18,8 +20,13 @@ jest.mock('@react-navigation/native', () => {
|
|
|
18
20
|
};
|
|
19
21
|
});
|
|
20
22
|
|
|
23
|
+
const wrapComponent = (route) => (
|
|
24
|
+
<SCProvider initState={mockSCStore({})}>
|
|
25
|
+
<ConnectedGateway route={route} />
|
|
26
|
+
</SCProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
21
29
|
describe('Test ConnectedGateway', () => {
|
|
22
|
-
const t = useTranslations();
|
|
23
30
|
let tree;
|
|
24
31
|
let route;
|
|
25
32
|
|
|
@@ -49,7 +56,7 @@ describe('Test ConnectedGateway', () => {
|
|
|
49
56
|
|
|
50
57
|
test('create', async () => {
|
|
51
58
|
await act(async () => {
|
|
52
|
-
tree = await create(
|
|
59
|
+
tree = await create(wrapComponent(route));
|
|
53
60
|
});
|
|
54
61
|
const instance = tree.root;
|
|
55
62
|
|
|
@@ -58,9 +65,11 @@ describe('Test ConnectedGateway', () => {
|
|
|
58
65
|
const textChipName = getText(instance, TESTID.CONNECTED_GATEWAY_CHIP_NAME);
|
|
59
66
|
const textDone = getText(instance, TESTID.CONNECTED_GATEWAY_DONE);
|
|
60
67
|
|
|
61
|
-
expect(textSuccess.props.children).toEqual(
|
|
68
|
+
expect(textSuccess.props.children).toEqual(
|
|
69
|
+
getTranslate('en', 'successfully_connected')
|
|
70
|
+
);
|
|
62
71
|
expect(textUnitName.props.children).toEqual('Unit name');
|
|
63
72
|
expect(textChipName.props.children).toEqual('Chip name - ABC123');
|
|
64
|
-
expect(textDone.props.children).toEqual(
|
|
73
|
+
expect(textDone.props.children).toEqual(getTranslate('en', 'done'));
|
|
65
74
|
});
|
|
66
75
|
});
|
|
@@ -4,9 +4,11 @@ import axios from 'axios';
|
|
|
4
4
|
|
|
5
5
|
import ConnectingGateway from '../ConnectingGateway';
|
|
6
6
|
import Text from '../../../commons/Text';
|
|
7
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
8
7
|
import API from '../../../configs/API';
|
|
9
8
|
import Routes from '../../../utils/Route';
|
|
9
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
10
|
+
import { SCProvider } from '../../../context';
|
|
11
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
10
12
|
|
|
11
13
|
jest.mock('axios');
|
|
12
14
|
|
|
@@ -20,8 +22,13 @@ jest.mock('@react-navigation/native', () => {
|
|
|
20
22
|
};
|
|
21
23
|
});
|
|
22
24
|
|
|
25
|
+
const wrapComponent = (route) => (
|
|
26
|
+
<SCProvider initState={mockSCStore({})}>
|
|
27
|
+
<ConnectingGateway route={route} />
|
|
28
|
+
</SCProvider>
|
|
29
|
+
);
|
|
30
|
+
|
|
23
31
|
describe('Test ConnectingGateway', () => {
|
|
24
|
-
const t = useTranslations();
|
|
25
32
|
let tree;
|
|
26
33
|
let route;
|
|
27
34
|
|
|
@@ -42,14 +49,16 @@ describe('Test ConnectingGateway', () => {
|
|
|
42
49
|
|
|
43
50
|
test('create', async () => {
|
|
44
51
|
await act(async () => {
|
|
45
|
-
tree = await create(
|
|
52
|
+
tree = await create(wrapComponent(route));
|
|
46
53
|
});
|
|
47
54
|
const instance = tree.root;
|
|
48
55
|
const texts = instance.findAllByType(Text);
|
|
49
|
-
expect(texts).toHaveLength(
|
|
50
|
-
expect(texts[0].props.children).toEqual(
|
|
56
|
+
expect(texts).toHaveLength(6);
|
|
57
|
+
expect(texts[0].props.children).toEqual(
|
|
58
|
+
getTranslate('en', 'connecting_your_gateway')
|
|
59
|
+
);
|
|
51
60
|
expect(texts[1].props.children).toEqual(
|
|
52
|
-
|
|
61
|
+
getTranslate('en', 'dont_turn_off_the_device_or_close_this_app')
|
|
53
62
|
);
|
|
54
63
|
});
|
|
55
64
|
|
|
@@ -64,18 +73,18 @@ describe('Test ConnectingGateway', () => {
|
|
|
64
73
|
});
|
|
65
74
|
|
|
66
75
|
await act(async () => {
|
|
67
|
-
tree = await create(
|
|
76
|
+
tree = await create(wrapComponent(route));
|
|
68
77
|
});
|
|
69
78
|
await act(async () => {
|
|
70
79
|
await jest.runOnlyPendingTimers();
|
|
71
80
|
});
|
|
72
81
|
expect(setInterval).toHaveBeenCalled();
|
|
73
|
-
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED, {
|
|
82
|
+
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
|
|
74
83
|
params: {
|
|
75
84
|
chip_id: 1,
|
|
76
85
|
},
|
|
77
86
|
});
|
|
78
|
-
expect(mockedNavigate).toHaveBeenCalledWith(
|
|
87
|
+
expect(mockedNavigate).not.toHaveBeenCalledWith(
|
|
79
88
|
Routes.ConnectedGateway,
|
|
80
89
|
route.params
|
|
81
90
|
);
|
|
@@ -92,13 +101,13 @@ describe('Test ConnectingGateway', () => {
|
|
|
92
101
|
});
|
|
93
102
|
|
|
94
103
|
await act(async () => {
|
|
95
|
-
tree = await create(
|
|
104
|
+
tree = await create(wrapComponent(route));
|
|
96
105
|
});
|
|
97
106
|
await act(async () => {
|
|
98
107
|
await jest.runOnlyPendingTimers();
|
|
99
108
|
});
|
|
100
109
|
expect(setInterval).toHaveBeenCalled();
|
|
101
|
-
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED, {
|
|
110
|
+
expect(axios.get).toHaveBeenCalledWith(API.CHIP.CHECK_FINALIZED(), {
|
|
102
111
|
params: {
|
|
103
112
|
chip_id: 1,
|
|
104
113
|
},
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform, TextInput, TouchableOpacity } from 'react-native';
|
|
4
|
+
import { act, create } from 'react-test-renderer';
|
|
5
|
+
|
|
6
|
+
import AddNewOneTap from '..';
|
|
7
|
+
import { TESTID } from '../../../configs/Constants';
|
|
8
|
+
import { SCProvider } from '../../../context';
|
|
9
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
10
|
+
import Routes from '../../../utils/Route';
|
|
11
|
+
|
|
12
|
+
const wrapComponent = (route) => (
|
|
13
|
+
<SCProvider initState={mockSCStore({})}>
|
|
14
|
+
<AddNewOneTap route={route} />
|
|
15
|
+
</SCProvider>
|
|
16
|
+
);
|
|
17
|
+
jest.mock('axios');
|
|
18
|
+
|
|
19
|
+
jest.mock('react-redux', () => {
|
|
20
|
+
return {
|
|
21
|
+
...jest.requireActual('react-redux'),
|
|
22
|
+
useSelector: () => 'vi',
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const mockedNavigate = jest.fn();
|
|
27
|
+
jest.mock('@react-navigation/native', () => {
|
|
28
|
+
return {
|
|
29
|
+
...jest.requireActual('@react-navigation/native'),
|
|
30
|
+
useNavigation: () => ({
|
|
31
|
+
navigate: mockedNavigate,
|
|
32
|
+
}),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
jest.mock('axios');
|
|
37
|
+
let tree;
|
|
38
|
+
|
|
39
|
+
describe('test AddNewOneTap', () => {
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
axios.post.mockClear();
|
|
42
|
+
mockedNavigate.mockClear();
|
|
43
|
+
});
|
|
44
|
+
test('create AddNewOneTap success', async () => {
|
|
45
|
+
Platform.OS = 'ios';
|
|
46
|
+
let route = {
|
|
47
|
+
params: { type: 'one_tap', unit: { id: 1 } },
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const response = {
|
|
51
|
+
status: 200,
|
|
52
|
+
data: {
|
|
53
|
+
id: 1,
|
|
54
|
+
unit: 1,
|
|
55
|
+
type: 'one_tap',
|
|
56
|
+
weekday_repeat: [],
|
|
57
|
+
script: { id: 1, name: 'William Miller' },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
axios.post.mockImplementation(async () => {
|
|
62
|
+
return response;
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await act(async () => {
|
|
66
|
+
tree = await create(wrapComponent(route));
|
|
67
|
+
});
|
|
68
|
+
const instance = tree.root;
|
|
69
|
+
const inputName = instance.findAll(
|
|
70
|
+
(el) =>
|
|
71
|
+
el.props.testID === TESTID.NAME_YOUR_BUTTON && el.type === TextInput
|
|
72
|
+
);
|
|
73
|
+
expect(inputName).toHaveLength(1);
|
|
74
|
+
|
|
75
|
+
await act(async () => {
|
|
76
|
+
await inputName[0].props.onChangeText('Tap to up');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const item = instance.findAll(
|
|
80
|
+
(el) =>
|
|
81
|
+
el.props.testID === TESTID.BOTTOM_VIEW_MAIN &&
|
|
82
|
+
el.type === TouchableOpacity
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
expect(item).toHaveLength(1);
|
|
86
|
+
await act(async () => {
|
|
87
|
+
await item[0].props.onPress();
|
|
88
|
+
});
|
|
89
|
+
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ScriptDetail, {
|
|
90
|
+
havePermission: true,
|
|
91
|
+
id: 1,
|
|
92
|
+
type: 'one_tap',
|
|
93
|
+
name: 'Tap to up',
|
|
94
|
+
unit: {
|
|
95
|
+
id: 1,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
test('create AddNewOneTap fail', async () => {
|
|
100
|
+
Platform.OS = 'android';
|
|
101
|
+
let route = {
|
|
102
|
+
params: { type: 'one_tap' },
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const response = {
|
|
106
|
+
status: 400,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
axios.post.mockImplementation(async () => {
|
|
110
|
+
return response;
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
await act(async () => {
|
|
114
|
+
tree = await create(wrapComponent(route));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const item = tree.root.findAll(
|
|
118
|
+
(el) =>
|
|
119
|
+
el.props.testID === TESTID.BOTTOM_VIEW_MAIN &&
|
|
120
|
+
el.type === TouchableOpacity
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
expect(item).toHaveLength(1);
|
|
124
|
+
await act(async () => {
|
|
125
|
+
await item[0].props.onPress();
|
|
126
|
+
});
|
|
127
|
+
expect(mockedNavigate).not.toBeCalled();
|
|
128
|
+
});
|
|
129
|
+
});
|
|
@@ -2,7 +2,7 @@ import React, { memo, useCallback, useState } from 'react';
|
|
|
2
2
|
import { ScrollView, SafeAreaView, Platform } from 'react-native';
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
|
|
5
|
-
import { Colors } from '../../configs';
|
|
5
|
+
import { API, Colors } from '../../configs';
|
|
6
6
|
import { TESTID } from '../../configs/Constants';
|
|
7
7
|
import _TextInput from '../../commons/Form/TextInput';
|
|
8
8
|
import styles from './AddNewOneTapStyles';
|
|
@@ -10,19 +10,31 @@ import { HeaderCustom } from '../../commons/Header';
|
|
|
10
10
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
11
11
|
import Text from '../../commons/Text';
|
|
12
12
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
13
|
-
import
|
|
13
|
+
import { axiosPost } from '../../utils/Apis/axios';
|
|
14
|
+
import Routes from '../../utils/Route';
|
|
14
15
|
|
|
15
16
|
const AddNewOneTap = memo(({ route }) => {
|
|
17
|
+
const { type, unit } = route.params;
|
|
16
18
|
const t = useTranslations();
|
|
17
19
|
const { navigate } = useNavigation();
|
|
18
|
-
const [name, setName] = useState('
|
|
20
|
+
const [name, setName] = useState(t('tap_to_run'));
|
|
19
21
|
|
|
20
|
-
const handleContinue = useCallback(() => {
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const handleContinue = useCallback(async () => {
|
|
23
|
+
const { success, data } = await axiosPost(API.AUTOMATE.CREATE_AUTOMATE(), {
|
|
24
|
+
unit: unit.id,
|
|
25
|
+
type: type,
|
|
23
26
|
name: name,
|
|
24
27
|
});
|
|
25
|
-
|
|
28
|
+
if (success) {
|
|
29
|
+
navigate(Routes.ScriptDetail, {
|
|
30
|
+
unit: unit,
|
|
31
|
+
id: data.id,
|
|
32
|
+
name: name,
|
|
33
|
+
type: type,
|
|
34
|
+
havePermission: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [type, name, unit, navigate]);
|
|
26
38
|
|
|
27
39
|
const onChangeName = useCallback((text) => {
|
|
28
40
|
setName(text);
|
|
@@ -53,6 +65,7 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
53
65
|
onChange={onChangeName}
|
|
54
66
|
textInputStyle={styles.textInput}
|
|
55
67
|
value={name}
|
|
68
|
+
testID={TESTID.NAME_YOUR_BUTTON}
|
|
56
69
|
/>
|
|
57
70
|
</ScrollView>
|
|
58
71
|
<BottomButtonView
|