@tarojs/taro-rn 4.0.0-beta.74 → 4.0.0-beta.76

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.
Files changed (182) hide show
  1. package/LICENSE +1 -8
  2. package/apiList.js +31 -31
  3. package/dist/api/index.js +1 -1
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/lib/Mask.js +2 -2
  6. package/dist/lib/Mask.js.map +1 -1
  7. package/dist/lib/Popup.js +3 -3
  8. package/dist/lib/Popup.js.map +1 -1
  9. package/dist/lib/StyleSheet.js +1 -1
  10. package/dist/lib/StyleSheet.js.map +1 -1
  11. package/dist/lib/accelerometer.js +1 -1
  12. package/dist/lib/accelerometer.js.map +1 -1
  13. package/dist/lib/chooseMedia/index.js.map +1 -1
  14. package/dist/lib/clearStorage/index.js +2 -2
  15. package/dist/lib/clearStorage/index.js.map +1 -1
  16. package/dist/lib/compressImage/index.js +1 -1
  17. package/dist/lib/compressImage/index.js.map +1 -1
  18. package/dist/lib/connectSocket/index.js.map +1 -1
  19. package/dist/lib/connectSocket/socketTask.js +1 -1
  20. package/dist/lib/connectSocket/socketTask.js.map +1 -1
  21. package/dist/lib/createCameraContext/index.js +3 -3
  22. package/dist/lib/createCameraContext/index.js.map +1 -1
  23. package/dist/lib/createInnerAudioContext/index.js +2 -2
  24. package/dist/lib/createInnerAudioContext/index.js.map +1 -1
  25. package/dist/lib/createVideoContext/index.js +7 -7
  26. package/dist/lib/createVideoContext/index.js.map +1 -1
  27. package/dist/lib/deviceMotion.js +2 -2
  28. package/dist/lib/deviceMotion.js.map +1 -1
  29. package/dist/lib/file.js +4 -4
  30. package/dist/lib/file.js.map +1 -1
  31. package/dist/lib/getAppBaseInfo/index.js +2 -2
  32. package/dist/lib/getAppBaseInfo/index.js.map +1 -1
  33. package/dist/lib/getClipboardData/index.js.map +1 -1
  34. package/dist/lib/getImageInfo/index.js +2 -2
  35. package/dist/lib/getImageInfo/index.js.map +1 -1
  36. package/dist/lib/getLocation/index.js +2 -2
  37. package/dist/lib/getLocation/index.js.map +1 -1
  38. package/dist/lib/getRecorderManager/index.js +5 -5
  39. package/dist/lib/getRecorderManager/index.js.map +1 -1
  40. package/dist/lib/getStorage/index.js.map +1 -1
  41. package/dist/lib/getStorageInfo/index.js +2 -2
  42. package/dist/lib/getStorageInfo/index.js.map +1 -1
  43. package/dist/lib/getSystemInfo/index.js +1 -1
  44. package/dist/lib/getSystemInfo/index.js.map +1 -1
  45. package/dist/lib/getSystemInfoSync/index.js +2 -2
  46. package/dist/lib/getSystemInfoSync/index.js.map +1 -1
  47. package/dist/lib/gyroscope.js +1 -1
  48. package/dist/lib/gyroscope.js.map +1 -1
  49. package/dist/lib/keyboard.js +3 -3
  50. package/dist/lib/keyboard.js.map +1 -1
  51. package/dist/lib/location.js.map +1 -1
  52. package/dist/lib/makePhoneCall/index.js +1 -1
  53. package/dist/lib/makePhoneCall/index.js.map +1 -1
  54. package/dist/lib/media.js +15 -13
  55. package/dist/lib/media.js.map +1 -1
  56. package/dist/lib/network.js +1 -1
  57. package/dist/lib/network.js.map +1 -1
  58. package/dist/lib/offWindowResize/index.js.map +1 -1
  59. package/dist/lib/onWindowResize/index.js +1 -1
  60. package/dist/lib/onWindowResize/index.js.map +1 -1
  61. package/dist/lib/openUrl/index.js +1 -1
  62. package/dist/lib/openUrl/index.js.map +1 -1
  63. package/dist/lib/permission.js +6 -5
  64. package/dist/lib/permission.js.map +1 -1
  65. package/dist/lib/previewImage/index.js +3 -3
  66. package/dist/lib/previewImage/index.js.map +1 -1
  67. package/dist/lib/request/index.js +1 -1
  68. package/dist/lib/request/index.js.map +1 -1
  69. package/dist/lib/scanCode/index.js +22 -22
  70. package/dist/lib/scanCode/index.js.map +1 -1
  71. package/dist/lib/screen.js +2 -2
  72. package/dist/lib/screen.js.map +1 -1
  73. package/dist/lib/setClipboardData/index.js +2 -2
  74. package/dist/lib/setClipboardData/index.js.map +1 -1
  75. package/dist/lib/setKeepScreenOn/index.js +1 -1
  76. package/dist/lib/setKeepScreenOn/index.js.map +1 -1
  77. package/dist/lib/setStorage/index.js.map +1 -1
  78. package/dist/lib/showActionSheet/ActionSheet.js +3 -3
  79. package/dist/lib/showActionSheet/ActionSheet.js.map +1 -1
  80. package/dist/lib/showActionSheet/index.js.map +1 -1
  81. package/dist/lib/showModal/Dialog.js +3 -3
  82. package/dist/lib/showModal/Dialog.js.map +1 -1
  83. package/dist/lib/showModal/index.js.map +1 -1
  84. package/dist/lib/showModal/toast.js +6 -6
  85. package/dist/lib/showModal/toast.js.map +1 -1
  86. package/dist/lib/unsupportedApi.js +2 -4
  87. package/dist/lib/unsupportedApi.js.map +1 -1
  88. package/dist/lib/variable.js +1 -1
  89. package/dist/lib/variable.js.map +1 -1
  90. package/dist/lib/vibrate.js +1 -1
  91. package/dist/lib/vibrate.js.map +1 -1
  92. package/dist/lib/window.js.map +1 -1
  93. package/dist/utils/callbackManager.js.map +1 -1
  94. package/dist/utils/index.js.map +1 -1
  95. package/package.json +65 -60
  96. package/src/api/index.ts +31 -31
  97. package/src/lib/ENV_TYPE/index.ts +1 -1
  98. package/src/lib/Mask.tsx +2 -2
  99. package/src/lib/Popup.tsx +8 -6
  100. package/src/lib/StyleSheet.ts +1 -1
  101. package/src/lib/accelerometer.ts +2 -1
  102. package/src/lib/arrayBufferToBase64/index.ts +1 -1
  103. package/src/lib/base64ToArrayBuffer/index.ts +1 -1
  104. package/src/lib/chooseMedia/index.ts +1 -1
  105. package/src/lib/clearStorage/index.ts +1 -0
  106. package/src/lib/clearStorageSync/index.ts +1 -1
  107. package/src/lib/compressImage/index.ts +1 -0
  108. package/src/lib/connectSocket/socketTask.ts +7 -9
  109. package/src/lib/createCameraContext/index.ts +6 -4
  110. package/src/lib/createInnerAudioContext/index.ts +1 -0
  111. package/src/lib/createSelectorQuery/index.ts +1 -1
  112. package/src/lib/deviceMotion.ts +4 -3
  113. package/src/lib/file.ts +9 -8
  114. package/src/lib/getClipboardData/index.ts +1 -0
  115. package/src/lib/getEnv/index.ts +1 -1
  116. package/src/lib/getFileSystemManager/index.ts +1 -1
  117. package/src/lib/getLocation/index.ts +4 -3
  118. package/src/lib/getRecorderManager/index.ts +1 -1
  119. package/src/lib/getStorage/index.ts +1 -0
  120. package/src/lib/getStorageInfo/index.ts +1 -0
  121. package/src/lib/getStorageInfoSync/index.ts +1 -1
  122. package/src/lib/getStorageSync/index.ts +1 -1
  123. package/src/lib/getSystemInfo/index.ts +2 -2
  124. package/src/lib/getSystemInfoSync/index.ts +3 -3
  125. package/src/lib/gyroscope.ts +47 -46
  126. package/src/lib/keyboard.ts +5 -4
  127. package/src/lib/location.ts +6 -5
  128. package/src/lib/makePhoneCall/index.ts +2 -1
  129. package/src/lib/media.ts +21 -18
  130. package/src/lib/network.ts +5 -5
  131. package/src/lib/offLocationChange/index.ts +1 -1
  132. package/src/lib/offUserCaptureScreen/index.ts +1 -1
  133. package/src/lib/onLocationChange/index.ts +1 -1
  134. package/src/lib/onUserCaptureScreen/index.ts +1 -1
  135. package/src/lib/onWindowResize/index.ts +2 -2
  136. package/src/lib/openUrl/index.d.ts +23 -22
  137. package/src/lib/openUrl/index.ts +2 -1
  138. package/src/lib/permission.ts +33 -25
  139. package/src/lib/previewImage/index.tsx +4 -3
  140. package/src/lib/removeStorageSync/index.ts +1 -1
  141. package/src/lib/request/index.ts +2 -2
  142. package/src/lib/scanCode/index.tsx +17 -15
  143. package/src/lib/screen.ts +1 -0
  144. package/src/lib/setClipboardData/index.ts +3 -2
  145. package/src/lib/setKeepScreenOn/index.ts +2 -1
  146. package/src/lib/setStorage/index.ts +1 -0
  147. package/src/lib/setStorageSync/index.ts +1 -1
  148. package/src/lib/showActionSheet/ActionSheet.tsx +7 -6
  149. package/src/lib/showActionSheet/index.tsx +1 -0
  150. package/src/lib/showModal/Dialog.tsx +7 -6
  151. package/src/lib/showModal/index.tsx +1 -0
  152. package/src/lib/showModal/toast.tsx +12 -11
  153. package/src/lib/startGyroscope/index.ts +1 -1
  154. package/src/lib/startLocationUpdate/index.ts +1 -1
  155. package/src/lib/unsupportedApi.ts +3 -5
  156. package/src/lib/vibrate.ts +11 -10
  157. package/src/lib/window.ts +3 -2
  158. package/src/utils/callbackManager.ts +5 -5
  159. package/src/utils/index.ts +4 -4
  160. package/{src/types → types}/vue/index.d.ts +2 -3
  161. package/dist/setup.js +0 -58
  162. package/dist/setup.js.map +0 -1
  163. package/src/__tests__/__mock__/mockRNCCameraRoll.js +0 -7
  164. package/src/__tests__/__mock__/mockRNCGeolocation.js +0 -13
  165. package/src/__tests__/__snapshots__/scanCode.test.tsx.snap +0 -154
  166. package/src/__tests__/clipboard.test.ts +0 -88
  167. package/src/__tests__/deviceMotion.test.ts +0 -37
  168. package/src/__tests__/geolocation.test.ts +0 -60
  169. package/src/__tests__/interactive.test.tsx +0 -101
  170. package/src/__tests__/keyboard.test.ts +0 -46
  171. package/src/__tests__/media.test.ts +0 -104
  172. package/src/__tests__/network.test.ts +0 -57
  173. package/src/__tests__/others.test.ts +0 -25
  174. package/src/__tests__/phone.test.ts +0 -31
  175. package/src/__tests__/request.test.ts +0 -146
  176. package/src/__tests__/scanCode.test.tsx +0 -14
  177. package/src/__tests__/storage.test.ts +0 -202
  178. package/src/__tests__/system.test.ts +0 -69
  179. package/src/__tests__/vibrate.test.ts +0 -27
  180. package/src/__tests__/websocket.test.ts +0 -170
  181. package/src/setup.ts +0 -64
  182. /package/{src/types → types}/definition.d.ts +0 -0
@@ -1 +1 @@
1
- export { setStorageSync } from '../unsupportedApi'
1
+ export { setStorageSync } from '../unsupportedApi'
@@ -1,14 +1,15 @@
1
- import React from 'react'
1
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types'
2
2
  import PropTypes from 'prop-types'
3
+ import React from 'react'
3
4
  import {
4
- View,
5
+ Platform,
6
+ StyleSheet,
5
7
  Text,
6
8
  TouchableHighlight,
7
- StyleSheet,
8
- Platform
9
+ View
9
10
  } from 'react-native'
10
- import { ViewPropTypes } from 'deprecated-react-native-prop-types'
11
- import { initialWindowMetrics } from 'react-native-safe-area-context';
11
+ import { initialWindowMetrics } from 'react-native-safe-area-context'
12
+
12
13
  import { Popup } from '../Popup'
13
14
  import V from '../variable'
14
15
 
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import RootSiblings from 'react-native-root-siblings'
3
+
3
4
  import ActionSheet from './ActionSheet'
4
5
 
5
6
  function showActionSheet (obj: Taro.showActionSheet.Option): Promise<Taro.showActionSheet.SuccessCallbackResult> {
@@ -1,14 +1,15 @@
1
- import React from 'react'
1
+ import { TextPropTypes, ViewPropTypes } from 'deprecated-react-native-prop-types'
2
2
  import PropTypes from 'prop-types'
3
+ import React from 'react'
3
4
  import {
4
- View,
5
- Text,
6
- TouchableHighlight,
7
5
  Dimensions,
6
+ Platform,
8
7
  StyleSheet,
9
- Platform
8
+ Text,
9
+ TouchableHighlight,
10
+ View
10
11
  } from 'react-native'
11
- import { ViewPropTypes, TextPropTypes } from 'deprecated-react-native-prop-types'
12
+
12
13
  import { Mask } from '../Mask'
13
14
  import { create } from '../StyleSheet'
14
15
  import V from '../variable'
@@ -1,6 +1,7 @@
1
1
  import React from 'react'
2
2
  import { Text } from 'react-native'
3
3
  import RootSiblings from 'react-native-root-siblings'
4
+
4
5
  import Dialog from './Dialog'
5
6
 
6
7
  function showModal (obj: Taro.showModal.Option): Promise<Taro.showModal.SuccessCallbackResult> {
@@ -1,10 +1,11 @@
1
- import React from 'react'
2
1
  import PropTypes from 'prop-types'
3
- import { View, Text, Image, StyleSheet, ActivityIndicator } from 'react-native'
2
+ import React from 'react'
3
+ import { ActivityIndicator, Image, StyleSheet, Text, View } from 'react-native'
4
4
  import RootSiblings from 'react-native-root-siblings'
5
- import successPng from './success.png'
6
- import errorPng from './error.png'
5
+
7
6
  import { errorHandler, shouldBeObject, successHandler } from '../../utils'
7
+ import errorPng from './error.png'
8
+ import successPng from './success.png'
8
9
 
9
10
  const globalAny: any = global
10
11
 
@@ -159,7 +160,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
159
160
  try {
160
161
  // setTimeout fires incorrectly when using chrome debug #4470
161
162
  // https://github.com/facebook/react-native/issues/4470
162
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
163
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
163
164
 
164
165
  globalAny.wxToastRootSiblings = new RootSiblings(ToastView)
165
166
  setTimeout(() => {
@@ -177,7 +178,7 @@ function showToast (options: Taro.showToast.Option): Promise<TaroGeneral.Callbac
177
178
  }
178
179
  }
179
180
 
180
- function showLoading (options: Taro.showLoading.Option = { title: "加载中" }): Promise<TaroGeneral.CallbackResult> {
181
+ function showLoading (options: Taro.showLoading.Option = { title: '加载中' }): Promise<TaroGeneral.CallbackResult> {
181
182
  const isObject = shouldBeObject(options)
182
183
  if (!isObject.res) {
183
184
  const res = { errMsg: `showLoading${isObject.msg}` }
@@ -202,7 +203,7 @@ function hideToast (opts: Taro.hideToast.Option = {}): void {
202
203
  const { success, fail, complete } = opts
203
204
 
204
205
  try {
205
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
206
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
206
207
  globalAny.wxToastRootSiblings = undefined
207
208
  const res = { errMsg: 'showToast:ok' }
208
209
  success?.(res)
@@ -218,7 +219,7 @@ function hideLoading (opts: Taro.hideLoading.Option = {}): void {
218
219
  const { success, fail, complete } = opts
219
220
 
220
221
  try {
221
- globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy();
222
+ globalAny.wxToastRootSiblings && globalAny.wxToastRootSiblings.destroy()
222
223
  globalAny.wxToastRootSiblings = undefined
223
224
  const res = { errMsg: 'showLoading:ok' }
224
225
  success?.(res)
@@ -231,8 +232,8 @@ function hideLoading (opts: Taro.hideLoading.Option = {}): void {
231
232
  }
232
233
 
233
234
  export {
234
- showToast,
235
- showLoading,
235
+ hideLoading,
236
236
  hideToast,
237
- hideLoading
237
+ showLoading,
238
+ showToast
238
239
  }
@@ -1 +1 @@
1
- export { startGyroscope } from '../gyroscope'
1
+ export { startGyroscope } from '../gyroscope'
@@ -1 +1 @@
1
- export { startLocationUpdate } from '../location'
1
+ export { startLocationUpdate } from '../location'
@@ -1,14 +1,12 @@
1
- function temporarilyNotSupport(apiName: String, recommended?: String, isSync = true) {
1
+ function temporarilyNotSupport(apiName: string, recommended?: string, isSync = true) {
2
2
  return () => {
3
3
  let errMsg = `RN 端暂不支持 API ${apiName}`
4
- if (!!recommended) {
4
+ if (recommended) {
5
5
  errMsg += `, 请使用 ${recommended}`
6
6
  }
7
7
  console.error(errMsg)
8
8
  if (!isSync) {
9
- return Promise.reject({
10
- errMsg
11
- })
9
+ return Promise.reject(new Error(errMsg))
12
10
  } else {
13
11
  return new Error(errMsg)
14
12
  }
@@ -1,16 +1,17 @@
1
1
  import { Vibration } from 'react-native'
2
+
2
3
  import { errorHandler, successHandler } from '../utils'
3
4
 
4
5
  function vibrate (DURATION, API, OPTS): Promise<TaroGeneral.CallbackResult> {
5
6
  const res = { errMsg: `${API}:ok` }
6
- const { success, fail, complete } = OPTS
7
- try {
8
- Vibration.vibrate(DURATION)
9
- return successHandler(success, complete)(res)
10
- } catch (err) {
11
- res.errMsg = err.message
12
- return errorHandler(fail, complete)(res)
13
- }
7
+ const { success, fail, complete } = OPTS
8
+ try {
9
+ Vibration.vibrate(DURATION)
10
+ return successHandler(success, complete)(res)
11
+ } catch (err) {
12
+ res.errMsg = err.message
13
+ return errorHandler(fail, complete)(res)
14
+ }
14
15
  }
15
16
 
16
17
  function vibrateShort (opts: Taro.vibrateShort.Option = {}): Promise<TaroGeneral.CallbackResult> {
@@ -22,6 +23,6 @@ function vibrateLong (opts: Taro.vibrateLong.Option = {}): Promise<TaroGeneral.C
22
23
  }
23
24
 
24
25
  export {
25
- vibrateShort,
26
- vibrateLong
26
+ vibrateLong,
27
+ vibrateShort
27
28
  }
package/src/lib/window.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ScaledSize, Dimensions, EmitterSubscription } from 'react-native'
1
+ import { Dimensions, EmitterSubscription, ScaledSize } from 'react-native'
2
+
2
3
  import { createCallbackManager } from '../utils'
3
4
 
4
5
  let listener: EmitterSubscription
@@ -18,4 +19,4 @@ export const addListener = () => {
18
19
 
19
20
  export const removeListener = () => {
20
21
  listener?.remove()
21
- }
22
+ }
@@ -1,9 +1,9 @@
1
1
  interface CallbackManager {
2
- add: (opt: any) => void;
3
- remove: (opt: any) => void;
4
- clear: () => void;
5
- count: () => number;
6
- trigger: (...args: any[]) => void;
2
+ add: (opt: any) => void
3
+ remove: (opt: any) => void
4
+ clear: () => void
5
+ count: () => number
6
+ trigger: (...args: any[]) => void
7
7
  }
8
8
 
9
9
  export function createCallbackManager(): CallbackManager {
@@ -1,11 +1,11 @@
1
1
  interface ShouldBeObjectResult {
2
- res: boolean;
3
- msg?: string;
2
+ res: boolean
3
+ msg?: string
4
4
  }
5
5
 
6
6
  interface GetParameterErrorOption {
7
- correct: string;
8
- wrong: any;
7
+ correct: string
8
+ wrong: any
9
9
  }
10
10
 
11
11
  function upperCaseFirstLetter (string: string): string {
@@ -1,6 +1,5 @@
1
-
2
1
  declare namespace Vue {
3
- interface ComponentOptions<T>{}
4
- }
2
+ interface ComponentOptions<T>{}
3
+ }
5
4
 
6
5
  declare interface Vue {}
package/dist/setup.js DELETED
@@ -1,58 +0,0 @@
1
- import '@testing-library/jest-native/extend-expect';
2
- import { NetInfoStateType } from '@react-native-community/netinfo';
3
- import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock';
4
- import mockRNCAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
5
- import mockRNCDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
6
- import mockRNCClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock';
7
- import mockRNCGeolocation from './__tests__/__mock__/mockRNCGeolocation';
8
- import mockRNCameraRoll from './__tests__/__mock__/mockRNCCameraRoll';
9
- jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
10
- jest.doMock('@react-native-community/netinfo', () => (Object.assign(Object.assign({}, mockRNCNetInfo), { NetInfoStateType })));
11
- jest.doMock('@react-native-async-storage/async-storage', () => mockRNCAsyncStorage);
12
- jest.doMock('@react-native-community/geolocation', () => mockRNCGeolocation);
13
- jest.doMock('@react-native-clipboard/clipboard', () => mockRNCClipboard);
14
- jest.doMock('react-native-device-info', () => mockRNCDeviceInfo);
15
- jest.mock('@react-native-camera-roll/camera-roll', () => mockRNCameraRoll);
16
- jest.mock('react-native', () => {
17
- const ReactNative = jest.requireActual('react-native');
18
- ReactNative.Image.getSize = jest.fn((_uri, success) => {
19
- setTimeout(() => success && success(320, 240));
20
- return Promise.resolve([320, 240]);
21
- });
22
- return ReactNative;
23
- });
24
- jest.doMock('expo-modules-core', () => {
25
- const unimodules = jest.requireActual('expo-modules-core');
26
- const { NativeModulesProxy } = unimodules;
27
- NativeModulesProxy.ExpoLocation = {
28
- getCurrentPositionAsync: jest.fn(() => Promise.resolve({
29
- coords: {
30
- latitude: 0,
31
- longitude: 0,
32
- speed: 0,
33
- accuracy: 0,
34
- altitude: 0
35
- }
36
- }))
37
- };
38
- return unimodules;
39
- });
40
- const grantedPromise = jest.fn(() => Promise.resolve({
41
- granted: true
42
- }));
43
- jest.doMock('expo-image-picker', () => {
44
- const expoImagePicker = jest.requireActual('expo-image-picker');
45
- expoImagePicker.requestMediaLibraryPermissionsAsync = grantedPromise;
46
- return expoImagePicker;
47
- });
48
- jest.doMock('expo-location', () => {
49
- const expoLocation = jest.requireActual('expo-location');
50
- expoLocation.requestForegroundPermissionsAsync = grantedPromise;
51
- return expoLocation;
52
- });
53
- jest.doMock('expo-barcode-scanner', () => {
54
- const expoBarcodeSacnner = jest.requireActual('expo-barcode-scanner');
55
- expoBarcodeSacnner.requestPermissionsAsync = grantedPromise;
56
- return expoBarcodeSacnner;
57
- });
58
- //# sourceMappingURL=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AAe,CAAQ,CAAA;IAC/D,YAAY,CAAC,iCAAiC,GAAG,cAAc,CAAA;IAC/D,OAAO,YAAY,CAAA;AACrB,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,MAAM,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACvC,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAQ,CAAA;IAC5E,kBAAkB,CAAC,uBAAuB,GAAG,cAAc,CAAA;IAC3D,OAAO,kBAAkB,CAAA;AAC3B,CAAC,CAAC,CAAA"}
@@ -1,7 +0,0 @@
1
- const CameraRoll = {
2
- save: jest.fn((url, { type }) => Promise.resolve(`${type}://${url}`)),
3
- }
4
-
5
- export default {
6
- CameraRoll,
7
- }
@@ -1,13 +0,0 @@
1
- export const mockGetCurrentPosition = jest.fn()
2
-
3
- const RNCGeolocation = {
4
- addListener: jest.fn(),
5
- getCurrentPosition: mockGetCurrentPosition,
6
- removeListeners: jest.fn(),
7
- requestAuthorization: jest.fn(),
8
- setConfiguration: jest.fn(),
9
- startObserving: jest.fn(),
10
- stopObserving: jest.fn(),
11
- }
12
-
13
- export default RNCGeolocation
@@ -1,154 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`scanCode should render scanCode success 1`] = `
4
- <View
5
- style={
6
- [
7
- {
8
- "alignItems": "center",
9
- "backgroundColor": "#FFF",
10
- "flex": 1,
11
- "justifyContent": "center",
12
- "position": "absolute",
13
- "zIndex": 1000,
14
- },
15
- ]
16
- }
17
- >
18
- <ViewManagerAdapter_ExpoCamera
19
- barCodeScannerEnabled={true}
20
- barCodeScannerSettings={
21
- {
22
- "barCodeTypes": [],
23
- }
24
- }
25
- faceDetectorSettings={{}}
26
- focusDepth={0}
27
- onBarCodeScanned={[Function]}
28
- onCameraReady={[Function]}
29
- onFacesDetected={[Function]}
30
- onMountError={[Function]}
31
- onPictureSaved={[Function]}
32
- onResponsiveOrientationChanged={[Function]}
33
- style={
34
- {
35
- "height": 1334,
36
- "width": 750,
37
- }
38
- }
39
- zoom={0}
40
- />
41
- <View
42
- accessibilityLabel="Close"
43
- accessibilityState={
44
- {
45
- "busy": undefined,
46
- "checked": undefined,
47
- "disabled": undefined,
48
- "expanded": undefined,
49
- "selected": undefined,
50
- }
51
- }
52
- accessibilityValue={
53
- {
54
- "max": undefined,
55
- "min": undefined,
56
- "now": undefined,
57
- "text": undefined,
58
- }
59
- }
60
- accessible={true}
61
- collapsable={false}
62
- focusable={true}
63
- onClick={[Function]}
64
- onResponderGrant={[Function]}
65
- onResponderMove={[Function]}
66
- onResponderRelease={[Function]}
67
- onResponderTerminate={[Function]}
68
- onResponderTerminationRequest={[Function]}
69
- onStartShouldSetResponder={[Function]}
70
- style={
71
- {
72
- "left": 20,
73
- "opacity": 1,
74
- "position": "absolute",
75
- "top": 10,
76
- }
77
- }
78
- >
79
- <View
80
- style={
81
- {
82
- "paddingTop": 20,
83
- }
84
- }
85
- >
86
- <Image
87
- source={1}
88
- style={
89
- {
90
- "height": 25,
91
- "marginTop": null,
92
- "width": 25,
93
- }
94
- }
95
- />
96
- </View>
97
- </View>
98
- <View
99
- accessibilityState={
100
- {
101
- "busy": undefined,
102
- "checked": undefined,
103
- "disabled": undefined,
104
- "expanded": undefined,
105
- "selected": undefined,
106
- }
107
- }
108
- accessibilityValue={
109
- {
110
- "max": undefined,
111
- "min": undefined,
112
- "now": undefined,
113
- "text": undefined,
114
- }
115
- }
116
- accessible={true}
117
- collapsable={false}
118
- focusable={true}
119
- onClick={[Function]}
120
- onResponderGrant={[Function]}
121
- onResponderMove={[Function]}
122
- onResponderRelease={[Function]}
123
- onResponderTerminate={[Function]}
124
- onResponderTerminationRequest={[Function]}
125
- onStartShouldSetResponder={[Function]}
126
- style={
127
- {
128
- "bottom": 40,
129
- "opacity": 1,
130
- "position": "absolute",
131
- "right": 20,
132
- }
133
- }
134
- >
135
- <View
136
- style={
137
- {
138
- "paddingTop": 20,
139
- }
140
- }
141
- >
142
- <Image
143
- source={1}
144
- style={
145
- {
146
- "height": 20,
147
- "width": 20,
148
- }
149
- }
150
- />
151
- </View>
152
- </View>
153
- </View>
154
- `;
@@ -1,88 +0,0 @@
1
- import Clipboard from '@react-native-clipboard/clipboard'
2
- import { getClipboardData } from '../lib/getClipboardData'
3
- import { setClipboardData } from '../lib/setClipboardData'
4
-
5
- const Taro = {
6
- setClipboardData,
7
- getClipboardData
8
- }
9
-
10
- // 原生模块导出缺少 react_native_1.NativeModules.RNCClipboar setup mock
11
-
12
- describe('clipboard', () => {
13
- describe('setClipboardData', () => {
14
- test('should set value into Clipboard', async () => {
15
- const data = 'mockString'
16
- const success = jest.fn()
17
- const fail = jest.fn()
18
- const complete = jest.fn()
19
-
20
- expect.assertions(7)
21
- const res = await Taro.setClipboardData({
22
- data,
23
- success,
24
- fail,
25
- complete
26
- })
27
- const expectMsg = 'setClipboardData:ok'
28
- expect(success.mock.calls.length).toBe(1)
29
- expect(success.mock.calls[0][0]).toEqual({ data, errMsg: expectMsg })
30
- expect(fail.mock.calls.length).toBe(0)
31
- expect(complete.mock.calls.length).toBe(1)
32
- expect(complete.mock.calls[0][0]).toEqual({ data, errMsg: expectMsg })
33
- expect(res.errMsg).toMatch(expectMsg)
34
-
35
- const clipData = await Clipboard.getString()
36
- expect(clipData).toEqual(data)
37
- })
38
-
39
- test('should fail when data is not string', () => {
40
- const data = {}
41
- const success = jest.fn()
42
- const fail = jest.fn()
43
- const complete = jest.fn()
44
-
45
- // expect.assertions(6)
46
- return Taro.setClipboardData({
47
- // @ts-ignore
48
- data,
49
- success,
50
- fail,
51
- complete
52
- }).catch(err => {
53
- const expectErrMsg = 'setClipboardData:fail parameter error: parameter.data should be String'
54
- expect(success.mock.calls.length).toBe(0)
55
- expect(fail.mock.calls.length).toBe(1)
56
- expect(fail.mock.calls[0][0]).toEqual({ errMsg: expectErrMsg })
57
- expect(complete.mock.calls.length).toBe(1)
58
- expect(complete.mock.calls[0][0]).toEqual({ errMsg: expectErrMsg })
59
- expect(err.errMsg).toMatch(expectErrMsg)
60
- })
61
- })
62
- })
63
-
64
- describe('getClipboardData', () => {
65
- test('可以获得正确的剪切板数据', async () => {
66
- const data = 'mockString'
67
- const success = jest.fn()
68
- const fail = jest.fn()
69
- const complete = jest.fn()
70
-
71
- expect.assertions(6)
72
- Clipboard.setString(data)
73
-
74
- const res = await Taro.getClipboardData({
75
- success,
76
- fail,
77
- complete
78
- })
79
- const expectErrMsg = 'getClipboardData:ok'
80
- expect(success.mock.calls.length).toBe(1)
81
- expect(fail.mock.calls.length).toBe(0)
82
- expect(success.mock.calls[0][0]).toEqual({ data, errMsg: expectErrMsg })
83
- expect(complete.mock.calls.length).toBe(1)
84
- expect(complete.mock.calls[0][0]).toEqual({ data, errMsg: expectErrMsg })
85
- expect(res.data).toEqual(data)
86
- })
87
- })
88
- })
@@ -1,37 +0,0 @@
1
- // import { DeviceMotion } from 'expo-sensors'
2
- import * as Taro from '../lib/deviceMotion'
3
-
4
- describe('deviceMotion', () => {
5
- it('should startDeviceMotionListening success', () => {
6
- const success = jest.fn()
7
- const fail = jest.fn()
8
- const complete = jest.fn()
9
- Taro.startDeviceMotionListening({
10
- success,
11
- fail,
12
- complete,
13
- })
14
- expect(success.mock.calls.length).toBe(1)
15
- expect(fail.mock.calls.length).toBe(0)
16
- expect(success.mock.calls.length).toBe(1)
17
- })
18
- it('should stopDeviceMotionListening success', () => {
19
- const success = jest.fn()
20
- const fail = jest.fn()
21
- const complete = jest.fn()
22
- Taro.stopDeviceMotionListening({
23
- success,
24
- fail,
25
- complete,
26
- })
27
- expect(success.mock.calls.length).toBe(1)
28
- expect(fail.mock.calls.length).toBe(0)
29
- expect(success.mock.calls.length).toBe(1)
30
- })
31
- // it('should onDeviceMotionChange success', () => {
32
- // const change = jest.fn().mockImplementation((ret) => {
33
- // expect(0).toBe(0)
34
- // })
35
- // Taro.onDeviceMotionChange(change)
36
- // })
37
- })
@@ -1,60 +0,0 @@
1
- import * as Taro from '../lib/getLocation'
2
- import { mockGetCurrentPosition } from './__mock__/mockRNCGeolocation'
3
-
4
- describe('location', () => {
5
- describe('getLocation', () => {
6
- // test('定位功能返回正常参数', () => {
7
- // const success = jest.fn()
8
- // const fail = jest.fn()
9
- // const complete = jest.fn()
10
-
11
- // const expectData = {
12
- // latitude: expect.any(Number),
13
- // longitude: expect.any(Number),
14
- // speed: expect.any(Number),
15
- // accuracy: expect.any(Number),
16
- // altitude: expect.any(Number),
17
- // verticalAccuracy: expect.any(Number),
18
- // horizontalAccuracy: expect.any(Number),
19
- // }
20
-
21
- // expect.assertions(6)
22
-
23
- // return Taro.getLocation({
24
- // success,
25
- // fail,
26
- // complete
27
- // }).then((res) => {
28
- // expect(success.mock.calls.length).toBe(1)
29
- // expect(fail.mock.calls.length).toBe(0)
30
- // expect(complete.mock.calls.length).toBe(1)
31
- // expect(complete.mock.calls[0][0]).toEqual(expect.objectContaining(expectData))
32
- // expect(success.mock.calls[0][0]).toEqual(expect.objectContaining(expectData))
33
- // expect(res).toEqual(expect.objectContaining(expectData))
34
- // })
35
- // })
36
- test('定位方法正常调用', () => {
37
- const success = jest.fn()
38
- const fail = jest.fn()
39
- const complete = jest.fn()
40
-
41
- // const expectData = {
42
- // latitude: expect.any(Number),
43
- // longitude: expect.any(Number),
44
- // speed: expect.any(Number),
45
- // accuracy: expect.any(Number),
46
- // altitude: expect.any(Number),
47
- // verticalAccuracy: expect.any(Number),
48
- // horizontalAccuracy: expect.any(Number),
49
- // }
50
-
51
- Taro.getLocation({
52
- success,
53
- fail,
54
- complete
55
- }).then(() => {
56
- expect(mockGetCurrentPosition.mock.calls.length).toBe(1)
57
- })
58
- })
59
- })
60
- })