@eohjsc/react-native-smart-city 0.2.86 → 0.2.89
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/assets/images/Common/Calendar.svg +3 -0
- package/assets/images/Common/SmartPhone.svg +3 -0
- package/assets/images/Hanet/CaptureFaceID.svg +25 -0
- package/assets/images/Hanet/FaceFrame.svg +6 -0
- package/assets/images/brightnessBlack.svg +12 -0
- package/index.js +4 -0
- package/package.json +3 -3
- package/src/Images/SmartIr/AC.svg +14 -0
- package/src/Images/SmartIr/DIY.svg +3 -0
- package/src/Images/SmartIr/Fan.svg +10 -0
- package/src/Images/SmartIr/Fridge.svg +5 -0
- package/src/Images/SmartIr/Remote.svg +15 -0
- package/src/Images/SmartIr/SmartIr.svg +4 -0
- package/src/Images/SmartIr/TV.svg +10 -0
- package/src/Images/SmartIr/Union.svg +9 -0
- package/src/Images/SmartIr/WM.svg +11 -0
- package/src/Images/SmartIr/index.js +10 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +51 -0
- package/src/commons/ActionGroup/ColorPickerTemplateStyles.js +17 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/AutoLockStyles.js +40 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +65 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapperStyles.js +43 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +57 -0
- package/src/commons/ActionGroup/{OnOffSmartLock.js → OnOffSmartLock/OnOffSmartLock.js} +5 -5
- package/src/commons/ActionGroup/{OnOffSmartLockStyle.js → OnOffSmartLock/OnOffSmartLockStyle.js} +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +48 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscodeStyles.js +42 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/PasscodeListStyles.js +49 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +66 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +96 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/SetupGeneratePasscodeStyles.js +98 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +62 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/index.js +249 -0
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -1
- package/src/commons/ActionGroup/SliderRangeTemplate.js +64 -0
- package/src/commons/ActionGroup/{LightActionTemplateStyles.js → SliderRangeTemplateStyles.js} +0 -8
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +167 -186
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -1
- package/src/commons/ActionGroup/index.js +7 -4
- package/src/commons/BottomSheet/index.js +2 -1
- package/src/commons/Device/DisconnectedView.js +7 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.js +109 -0
- package/src/commons/Device/HistoryChart.js +2 -2
- package/src/commons/Device/HorizontalBarChart.js +7 -0
- package/src/commons/Device/ItemDevice.js +18 -15
- package/src/commons/Device/LinearChart.js +14 -41
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -2
- package/src/commons/RowItem/index.js +12 -7
- package/src/commons/SubUnit/Favorites/index.js +2 -2
- package/src/commons/SubUnit/ShortDetail.js +39 -20
- package/src/commons/WheelDateTimePicker/index.js +18 -4
- package/src/configs/API.js +23 -1
- package/src/configs/Colors.js +1 -0
- package/src/configs/Constants.js +48 -0
- package/src/configs/SCConfig.js +1 -1
- package/src/context/actionType.ts +4 -0
- package/src/context/mockStore.ts +3 -0
- package/src/context/reducer.ts +20 -0
- package/src/iot/RemoteControl/Bluetooth.js +3 -22
- package/src/iot/RemoteControl/index.js +0 -1
- package/src/navigations/HanetCameraStack.js +41 -0
- package/src/navigations/SmartIrStack.js +31 -0
- package/src/navigations/SmartLockStack.js +51 -0
- package/src/navigations/UnitStack.js +46 -4
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +79 -72
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +155 -27
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ConnectWifiWarning.test.js +65 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +26 -2
- package/src/screens/Device/__test__/detail.test.js +0 -10
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +13 -2
- package/src/screens/Device/detail.js +118 -38
- package/src/screens/Device/hooks/useDisconnectedDevice.js +28 -16
- package/src/screens/GuestInfo/components/AccessScheduleItem.js +9 -2
- package/src/screens/GuestInfo/components/RecurringDetail.js +3 -2
- package/src/screens/GuestInfo/components/TemporaryDetail.js +3 -2
- package/src/screens/GuestInfo/styles/AccessScheduleItemStyles.js +3 -0
- package/src/screens/HanetCamera/CaptureFaceID.js +210 -0
- package/src/screens/HanetCamera/Detail.js +252 -0
- package/src/screens/HanetCamera/ManageAccess.js +173 -0
- package/src/screens/HanetCamera/MemberInfo.js +208 -0
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +133 -0
- package/src/screens/HanetCamera/__test__/Detail.test.js +185 -0
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +152 -0
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +178 -0
- package/src/screens/HanetCamera/components/CheckinHeader.js +37 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +151 -0
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +71 -0
- package/src/screens/HanetCamera/hooks/index.js +5 -0
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +116 -0
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +86 -0
- package/src/screens/HanetCamera/hooks/useStateAlertAction.js +62 -0
- package/src/screens/HanetCamera/styles/captureFaceIDStyles.js +50 -0
- package/src/screens/HanetCamera/styles/checkinHeaderStyles.js +24 -0
- package/src/screens/HanetCamera/styles/detailStyles.js +107 -0
- package/src/screens/HanetCamera/styles/manageAccessStyles.js +49 -0
- package/src/screens/HanetCamera/styles/memberInfoStyles.js +73 -0
- package/src/screens/HanetCamera/utils/Monitor.js +52 -0
- package/src/screens/Notification/__test__/NotificationItem.test.js +1 -0
- package/src/screens/Notification/components/NotificationItem.js +16 -0
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +31 -0
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +80 -0
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +65 -0
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +57 -0
- package/src/screens/SmartIr/__test__/SmartIr.test.js +1 -0
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottom.js +45 -0
- package/src/screens/SmartIr/components/GroupButtonByType/ButtonsBottomStyles.js +31 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +208 -0
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByTypeStyles.js +113 -0
- package/src/screens/SmartIr/components/SelectBrand.js +61 -0
- package/src/screens/SmartIr/components/SelectBrandStyles.js +14 -0
- package/src/screens/SmartIr/components/SelectDeviceType.js +96 -0
- package/src/screens/SmartIr/components/SelectDeviceTypeStyles.js +30 -0
- package/src/screens/SmartIr/index.js +8 -3
- package/src/screens/Unit/Detail.js +7 -11
- package/src/screens/Unit/__test__/Detail.test.js +0 -10
- package/src/screens/Unit/components/MyUnitDevice/index.js +2 -4
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +38 -9
- package/src/utils/I18n/translations/en.json +51 -1
- package/src/utils/I18n/translations/vi.json +51 -1
- package/src/utils/Route/index.js +14 -1
- package/src/commons/ActionGroup/LightActionTemplate.js +0 -103
- package/src/commons/ActionGroup/__test__/LightActionTemplate.test.js +0 -59
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
backgroundColor: Colors.White,
|
|
8
|
+
},
|
|
9
|
+
headerRight: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
},
|
|
12
|
+
contentContainerStyle: {
|
|
13
|
+
paddingBottom: 60,
|
|
14
|
+
},
|
|
15
|
+
wrapItem: {
|
|
16
|
+
height: 100,
|
|
17
|
+
width: '100%',
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
padding: 16,
|
|
21
|
+
borderBottomWidth: 1,
|
|
22
|
+
borderBottomColor: Colors.Gray3,
|
|
23
|
+
},
|
|
24
|
+
itemAvatar: {
|
|
25
|
+
height: 48,
|
|
26
|
+
width: 48,
|
|
27
|
+
borderRadius: 24,
|
|
28
|
+
borderWidth: 1,
|
|
29
|
+
borderColor: Colors.Gray3,
|
|
30
|
+
},
|
|
31
|
+
itemName: {
|
|
32
|
+
marginLeft: 16,
|
|
33
|
+
flex: 1,
|
|
34
|
+
},
|
|
35
|
+
addMemberModal: {
|
|
36
|
+
paddingBottom: 50,
|
|
37
|
+
},
|
|
38
|
+
row: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
paddingVertical: 16,
|
|
42
|
+
marginHorizontal: 16,
|
|
43
|
+
borderBottomColor: Colors.Gray3,
|
|
44
|
+
borderBottomWidth: 1,
|
|
45
|
+
},
|
|
46
|
+
textOption: {
|
|
47
|
+
marginLeft: 18,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
container: {
|
|
6
|
+
flex: 1,
|
|
7
|
+
backgroundColor: Colors.White,
|
|
8
|
+
},
|
|
9
|
+
headerRight: {
|
|
10
|
+
flexDirection: 'row',
|
|
11
|
+
},
|
|
12
|
+
wrapAvatar: {
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
marginTop: 24,
|
|
15
|
+
marginBottom: 52,
|
|
16
|
+
},
|
|
17
|
+
avatar: {
|
|
18
|
+
height: 88,
|
|
19
|
+
width: 88,
|
|
20
|
+
borderRadius: 44,
|
|
21
|
+
borderWidth: 1,
|
|
22
|
+
borderColor: Colors.Gray3,
|
|
23
|
+
},
|
|
24
|
+
row: {
|
|
25
|
+
flexDirection: 'row',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
borderBottomWidth: 1,
|
|
28
|
+
borderBottomColor: Colors.Gray3,
|
|
29
|
+
height: 64,
|
|
30
|
+
marginHorizontal: 16,
|
|
31
|
+
},
|
|
32
|
+
textSetPhoto: {
|
|
33
|
+
flex: 1,
|
|
34
|
+
marginLeft: 16,
|
|
35
|
+
lineHeight: 24,
|
|
36
|
+
},
|
|
37
|
+
photoID: {
|
|
38
|
+
width: 42,
|
|
39
|
+
height: 42,
|
|
40
|
+
borderRadius: 6,
|
|
41
|
+
borderWidth: 1,
|
|
42
|
+
borderColor: Colors.Gray3,
|
|
43
|
+
},
|
|
44
|
+
spaceBetween: {
|
|
45
|
+
justifyContent: 'space-between',
|
|
46
|
+
},
|
|
47
|
+
buttonRemove: {
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
padding: 32,
|
|
51
|
+
bottom: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
},
|
|
55
|
+
textInput: {
|
|
56
|
+
margin: 16,
|
|
57
|
+
marginTop: 0,
|
|
58
|
+
borderWidth: 0,
|
|
59
|
+
paddingLeft: 0,
|
|
60
|
+
paddingTop: 0,
|
|
61
|
+
borderBottomWidth: 2,
|
|
62
|
+
borderBottomColor: Colors.Primary,
|
|
63
|
+
fontSize: 16,
|
|
64
|
+
color: Colors.Gray9,
|
|
65
|
+
},
|
|
66
|
+
bottomButton: {
|
|
67
|
+
paddingBottom: 24,
|
|
68
|
+
},
|
|
69
|
+
textError: {
|
|
70
|
+
marginHorizontal: 16,
|
|
71
|
+
marginTop: 4,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { API } from '../../../configs';
|
|
2
|
+
import Pusher from 'pusher-js/react-native';
|
|
3
|
+
import { SCConfig } from '../../../configs/SCConfig';
|
|
4
|
+
import { axiosPost } from '../../../utils/Apis/axios';
|
|
5
|
+
|
|
6
|
+
Pusher.logToConsole = true;
|
|
7
|
+
let pusher = null;
|
|
8
|
+
|
|
9
|
+
const getPusher = () => {
|
|
10
|
+
if (!pusher) {
|
|
11
|
+
pusher = new Pusher(SCConfig.pusherAppKey, {
|
|
12
|
+
cluster: SCConfig.pusherAppCluste,
|
|
13
|
+
authorizer: function (channel, option) {
|
|
14
|
+
return {
|
|
15
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
16
|
+
authorize: async function (socketId, callback) {
|
|
17
|
+
const { success, data } = await axiosPost(
|
|
18
|
+
API.CAMERA.HANET.PUSHER_AUTH(),
|
|
19
|
+
{
|
|
20
|
+
channel_name: channel.name,
|
|
21
|
+
socket_id: socketId,
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
if (success) {
|
|
25
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
26
|
+
callback(null, data);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return pusher;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const destroyPusher = () => {
|
|
37
|
+
pusher.disconnect();
|
|
38
|
+
pusher = null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
42
|
+
export const watchHanetCheckinData = (hanetCamera, callback) => {
|
|
43
|
+
const channel = getPusher().subscribe(
|
|
44
|
+
`private-hanet-camera-${hanetCamera.device_id}`
|
|
45
|
+
);
|
|
46
|
+
channel.bind('new-checkin-data', callback);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const unwatchHanetCheckinData = (hanetCamera) => {
|
|
50
|
+
getPusher().unsubscribe(`private-hanet-camera-${hanetCamera.device_id}`);
|
|
51
|
+
destroyPusher();
|
|
52
|
+
};
|
|
@@ -191,6 +191,7 @@ describe('test NotificationItem', () => {
|
|
|
191
191
|
SENSOR_TYPE.SMOKE,
|
|
192
192
|
SENSOR_TYPE.FIRE,
|
|
193
193
|
SENSOR_TYPE.SOS,
|
|
194
|
+
SENSOR_TYPE.FILTER_WATER,
|
|
194
195
|
];
|
|
195
196
|
for (const sensorType of listSensorType2) {
|
|
196
197
|
test(`create ItemNotification NOTIFY_INDICATOR sensor_type ${sensorType}`, () => {
|
|
@@ -352,6 +352,22 @@ const NotificationItem = memo(({ item }) => {
|
|
|
352
352
|
}),
|
|
353
353
|
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
354
354
|
};
|
|
355
|
+
case SENSOR_TYPE.FILTER_WATER:
|
|
356
|
+
return {
|
|
357
|
+
content: customColorText(
|
|
358
|
+
t('text_notification_content_replace_water_filter'),
|
|
359
|
+
arrParams
|
|
360
|
+
),
|
|
361
|
+
redirect: () =>
|
|
362
|
+
navigation.navigate(Routes.UnitStack, {
|
|
363
|
+
screen: Routes.DeviceDetail,
|
|
364
|
+
params: {
|
|
365
|
+
unitId,
|
|
366
|
+
sensorId,
|
|
367
|
+
},
|
|
368
|
+
}),
|
|
369
|
+
iconContent: <Image source={Images.logo} style={styles.logo} />,
|
|
370
|
+
};
|
|
355
371
|
default:
|
|
356
372
|
return {
|
|
357
373
|
content: customColorText(
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import { ButtonsBottom } from '../components/GroupButtonByType/ButtonsBottom';
|
|
4
|
+
import { SCProvider } from '../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
6
|
+
import { TouchableOpacity } from 'react-native';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = () => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ButtonsBottom />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
jest.mock('react', () => {
|
|
15
|
+
return {
|
|
16
|
+
...jest.requireActual('react'),
|
|
17
|
+
memo: (x) => x,
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
describe('Test ButtonsBottom', () => {
|
|
21
|
+
let tree;
|
|
22
|
+
|
|
23
|
+
test('render ButtonsBottom', () => {
|
|
24
|
+
act(() => {
|
|
25
|
+
tree = renderer.create(wrapComponent());
|
|
26
|
+
});
|
|
27
|
+
const instance = tree.root;
|
|
28
|
+
const touchableOpacity = instance.findAllByType(TouchableOpacity);
|
|
29
|
+
expect(touchableOpacity).toHaveLength(2);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer, { act } from 'react-test-renderer';
|
|
3
|
+
import GroupButtonByType from '../components/GroupButtonByType/GroupButtonByType';
|
|
4
|
+
import { SCProvider } from '../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
6
|
+
import WrapHeaderScrollable from '../../../commons/Sharing/WrapHeaderScrollable';
|
|
7
|
+
import { ButtonsBottom } from '../components/GroupButtonByType/ButtonsBottom';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (route) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<GroupButtonByType route={route} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const mockNavigate = jest.fn();
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useNavigation: () => ({
|
|
20
|
+
navigate: mockNavigate,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
jest.mock('react', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('react'),
|
|
27
|
+
memo: (x) => x,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
describe('Test GroupButtonByType', () => {
|
|
31
|
+
let tree;
|
|
32
|
+
test('render GroupButtonByType', () => {
|
|
33
|
+
const route = {
|
|
34
|
+
params: {
|
|
35
|
+
device_type: { id: 1, name: '', icon: '' },
|
|
36
|
+
brand: { id: 1, name: '' },
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
act(() => {
|
|
40
|
+
tree = renderer.create(wrapComponent(route));
|
|
41
|
+
});
|
|
42
|
+
const instance = tree.root;
|
|
43
|
+
const wrapHeaderScrollable = instance.findAllByType(WrapHeaderScrollable);
|
|
44
|
+
expect(wrapHeaderScrollable).toHaveLength(1);
|
|
45
|
+
});
|
|
46
|
+
test('onPressLeft ButtonsBottom', () => {
|
|
47
|
+
const route = {
|
|
48
|
+
params: {
|
|
49
|
+
device_type: { id: 1, name: '', icon: '' },
|
|
50
|
+
brand: { id: 1, name: '' },
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
act(() => {
|
|
54
|
+
tree = renderer.create(wrapComponent(route));
|
|
55
|
+
});
|
|
56
|
+
const instance = tree.root;
|
|
57
|
+
const buttonsBottom = instance.findAllByType(ButtonsBottom);
|
|
58
|
+
expect(buttonsBottom).toHaveLength(2);
|
|
59
|
+
act(() => {
|
|
60
|
+
buttonsBottom[0].props.onPressLeft();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test('onPressRight ButtonsBottom', () => {
|
|
64
|
+
const route = {
|
|
65
|
+
params: {
|
|
66
|
+
device_type: { id: 1, name: '', icon: '' },
|
|
67
|
+
brand: { id: 1, name: '' },
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
act(() => {
|
|
71
|
+
tree = renderer.create(wrapComponent(route));
|
|
72
|
+
});
|
|
73
|
+
const instance = tree.root;
|
|
74
|
+
const buttonsBottom = instance.findAllByType(ButtonsBottom);
|
|
75
|
+
expect(buttonsBottom).toHaveLength(2);
|
|
76
|
+
act(() => {
|
|
77
|
+
buttonsBottom[0].props.onPressRight();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView } from 'react-native';
|
|
3
|
+
import renderer, { act } from 'react-test-renderer';
|
|
4
|
+
import SelectBrand from '../components/SelectBrand';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
import { RowItem } from '../../../commons/RowItem';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (route) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<SelectBrand route={route} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const mockNavigate = jest.fn();
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useNavigation: () => ({
|
|
20
|
+
navigate: mockNavigate,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
jest.mock('react', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('react'),
|
|
27
|
+
memo: (x) => x,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
describe('Test SelectBrand', () => {
|
|
31
|
+
let tree;
|
|
32
|
+
test('render SelectBrand', () => {
|
|
33
|
+
const route = {
|
|
34
|
+
params: {
|
|
35
|
+
device_type: { id: 1, name: '' },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
act(() => {
|
|
39
|
+
tree = renderer.create(wrapComponent(route));
|
|
40
|
+
});
|
|
41
|
+
const instance = tree.root;
|
|
42
|
+
const scrollView = instance.findAllByType(ScrollView);
|
|
43
|
+
expect(scrollView).toHaveLength(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('Row SmartIr onPress', () => {
|
|
47
|
+
const route = {
|
|
48
|
+
params: {
|
|
49
|
+
device_type: { id: 1, name: '' },
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
act(() => {
|
|
53
|
+
tree = renderer.create(wrapComponent(route));
|
|
54
|
+
});
|
|
55
|
+
const instance = tree.root;
|
|
56
|
+
const scrollView = instance.findAllByType(ScrollView);
|
|
57
|
+
expect(scrollView).toHaveLength(1);
|
|
58
|
+
const rowItem = instance.findAllByType(RowItem);
|
|
59
|
+
expect(rowItem).toHaveLength(3);
|
|
60
|
+
act(() => {
|
|
61
|
+
rowItem[0].props.onPress();
|
|
62
|
+
});
|
|
63
|
+
expect(mockNavigate).toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
+
import renderer, { act } from 'react-test-renderer';
|
|
4
|
+
import SelectDeviceType from '../components/SelectDeviceType';
|
|
5
|
+
import { SCProvider } from '../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = () => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<SelectDeviceType />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const mockNavigate = jest.fn();
|
|
15
|
+
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useNavigation: () => ({
|
|
20
|
+
navigate: mockNavigate,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
jest.mock('react', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('react'),
|
|
27
|
+
memo: (x) => x,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
describe('Test SelectDeviceType', () => {
|
|
31
|
+
let tree;
|
|
32
|
+
|
|
33
|
+
test('render SelectDeviceType', () => {
|
|
34
|
+
act(() => {
|
|
35
|
+
tree = renderer.create(wrapComponent());
|
|
36
|
+
});
|
|
37
|
+
const instance = tree.root;
|
|
38
|
+
const scrollView = instance.findAllByType(ScrollView);
|
|
39
|
+
expect(scrollView).toHaveLength(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('itemDevice SelectDeviceType onPress', () => {
|
|
43
|
+
act(() => {
|
|
44
|
+
tree = renderer.create(wrapComponent());
|
|
45
|
+
});
|
|
46
|
+
const instance = tree.root;
|
|
47
|
+
const scrollView = instance.findAllByType(ScrollView);
|
|
48
|
+
expect(scrollView).toHaveLength(1);
|
|
49
|
+
const touchableOpacity = instance.findAllByType(TouchableOpacity);
|
|
50
|
+
expect(touchableOpacity).toHaveLength(7);
|
|
51
|
+
const itemDevice = touchableOpacity[1];
|
|
52
|
+
act(() => {
|
|
53
|
+
itemDevice.props.onPress();
|
|
54
|
+
});
|
|
55
|
+
expect(mockNavigate).toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
|
+
import Text from '../../../../commons/Text';
|
|
4
|
+
|
|
5
|
+
import { Colors } from '../../../../configs';
|
|
6
|
+
|
|
7
|
+
import styles from './ButtonsBottomStyles';
|
|
8
|
+
|
|
9
|
+
const ButtonsBottom = memo(
|
|
10
|
+
({
|
|
11
|
+
onPressLeft,
|
|
12
|
+
onPressRight,
|
|
13
|
+
textLeft,
|
|
14
|
+
colorTextLeft = Colors.White,
|
|
15
|
+
colorTextRight = Colors.Gray8,
|
|
16
|
+
leftButtonStyle,
|
|
17
|
+
rightButtonStyle,
|
|
18
|
+
buttonStyle = {},
|
|
19
|
+
textRight,
|
|
20
|
+
type = 'H4',
|
|
21
|
+
}) => {
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.ButtonsBottom}>
|
|
24
|
+
<TouchableOpacity
|
|
25
|
+
style={[styles.LeftButton, buttonStyle, leftButtonStyle]}
|
|
26
|
+
onPress={onPressLeft}
|
|
27
|
+
>
|
|
28
|
+
<Text type={type} color={colorTextLeft}>
|
|
29
|
+
{textLeft}
|
|
30
|
+
</Text>
|
|
31
|
+
</TouchableOpacity>
|
|
32
|
+
<TouchableOpacity
|
|
33
|
+
style={[styles.RightButton, buttonStyle, rightButtonStyle]}
|
|
34
|
+
onPress={onPressRight}
|
|
35
|
+
>
|
|
36
|
+
<Text type={type} color={colorTextRight}>
|
|
37
|
+
{textRight}
|
|
38
|
+
</Text>
|
|
39
|
+
</TouchableOpacity>
|
|
40
|
+
</View>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export { ButtonsBottom };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../../configs';
|
|
3
|
+
|
|
4
|
+
const flexCenter = {
|
|
5
|
+
justifyContent: 'center',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
};
|
|
8
|
+
const styleButton = {
|
|
9
|
+
paddingVertical: 8,
|
|
10
|
+
paddingHorizontal: 32,
|
|
11
|
+
borderRadius: 30,
|
|
12
|
+
marginHorizontal: 8,
|
|
13
|
+
};
|
|
14
|
+
export default StyleSheet.create({
|
|
15
|
+
ButtonsBottom: {
|
|
16
|
+
marginTop: 16,
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
},
|
|
19
|
+
LeftButton: {
|
|
20
|
+
backgroundColor: Colors.Primary,
|
|
21
|
+
...styleButton,
|
|
22
|
+
...flexCenter,
|
|
23
|
+
},
|
|
24
|
+
RightButton: {
|
|
25
|
+
backgroundColor: Colors.Gray1,
|
|
26
|
+
borderColor: Colors.Gray5,
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
...styleButton,
|
|
29
|
+
...flexCenter,
|
|
30
|
+
},
|
|
31
|
+
});
|