@eohjsc/react-native-smart-city 0.3.13 → 0.3.14
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/package.json
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { create, act } from 'react-test-renderer';
|
|
3
|
+
import Toast from 'react-native-toast-message';
|
|
4
|
+
|
|
3
5
|
import MockAdapter from 'axios-mock-adapter';
|
|
4
6
|
import { SCProvider } from '../../../context';
|
|
5
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
@@ -117,6 +119,30 @@ describe('Test ScriptDetail', () => {
|
|
|
117
119
|
expect(alertAction.props.visible).toBeFalsy();
|
|
118
120
|
});
|
|
119
121
|
|
|
122
|
+
test('test rename script failed', async () => {
|
|
123
|
+
await act(async () => {
|
|
124
|
+
tree = await create(wrapComponent(route));
|
|
125
|
+
});
|
|
126
|
+
const instance = tree.root;
|
|
127
|
+
const menu = instance.findByType(MenuActionMore);
|
|
128
|
+
const alertAction = instance.findByType(AlertAction);
|
|
129
|
+
const rename = menu.props.listMenuItem[0];
|
|
130
|
+
|
|
131
|
+
await act(async () => {
|
|
132
|
+
await menu.props.onItemClick(rename);
|
|
133
|
+
await menu.props.hideComplete();
|
|
134
|
+
});
|
|
135
|
+
expect(menu.props.isVisible).toBeFalsy();
|
|
136
|
+
expect(alertAction.props.visible).toBeTruthy();
|
|
137
|
+
|
|
138
|
+
mock.onPatch(API.AUTOMATE.SCRIPT(1)).reply(500, { name: 'new_name' });
|
|
139
|
+
await act(async () => {
|
|
140
|
+
await alertAction.props.rightButtonClick();
|
|
141
|
+
});
|
|
142
|
+
expect(alertAction.props.visible).toBeFalsy();
|
|
143
|
+
expect(Toast.show).toHaveBeenCalled();
|
|
144
|
+
});
|
|
145
|
+
|
|
120
146
|
test('test delete script', async () => {
|
|
121
147
|
await act(async () => {
|
|
122
148
|
tree = await create(wrapComponent(route));
|
|
@@ -99,9 +99,14 @@ const ScriptDetail = ({ route }) => {
|
|
|
99
99
|
name: inputName,
|
|
100
100
|
}
|
|
101
101
|
);
|
|
102
|
-
|
|
102
|
+
if (success) {
|
|
103
|
+
setScriptName(script.name);
|
|
104
|
+
ToastBottomHelper.success(t('rename_successfully'));
|
|
105
|
+
} else {
|
|
106
|
+
ToastBottomHelper.error(t('rename_failed'));
|
|
107
|
+
}
|
|
103
108
|
hideAlertAction();
|
|
104
|
-
}, [id, inputName, hideAlertAction]);
|
|
109
|
+
}, [id, inputName, hideAlertAction, t]);
|
|
105
110
|
|
|
106
111
|
const deleteScript = useCallback(async () => {
|
|
107
112
|
hideAlertAction();
|
|
@@ -113,12 +118,16 @@ const ScriptDetail = ({ route }) => {
|
|
|
113
118
|
} else {
|
|
114
119
|
goBack();
|
|
115
120
|
}
|
|
121
|
+
ToastBottomHelper.success(t('removed_successfully'));
|
|
122
|
+
} else {
|
|
123
|
+
ToastBottomHelper.error(t('remove_failed'));
|
|
116
124
|
}
|
|
117
125
|
}, [
|
|
118
126
|
hideAlertAction,
|
|
119
127
|
id,
|
|
120
128
|
isCreateScriptSuccess,
|
|
121
129
|
isCreateNewAction,
|
|
130
|
+
t,
|
|
122
131
|
dispatch,
|
|
123
132
|
isAutomateTab,
|
|
124
133
|
goBack,
|