1 Star 0 Fork 0

UnPourTous/react-native-permissions

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mock.js 2.08 KB
一键复制 编辑 原始数据 按行查看 历史
Mathieu Acthernoene 提交于 2022-03-09 14:32 . Bump to 3.3.1
const {
PERMISSIONS: {ANDROID},
} = require('./dist/commonjs/permissions.android');
const {
PERMISSIONS: {IOS},
} = require('./dist/commonjs/permissions.ios');
const {
PERMISSIONS: {WINDOWS},
} = require('./dist/commonjs/permissions.windows');
const {RESULTS} = require('./dist/commonjs/results');
const PERMISSIONS = {ANDROID, IOS, WINDOWS};
export {PERMISSIONS, RESULTS};
export const openLimitedPhotoLibraryPicker = jest.fn(async () => {});
export const openSettings = jest.fn(async () => {});
export const check = jest.fn(async (permission) => RESULTS.GRANTED);
export const request = jest.fn(async (permission) => RESULTS.GRANTED);
export const checkLocationAccuracy = jest.fn(async () => 'full');
export const requestLocationAccuracy = jest.fn(async (options) => 'full');
const notificationOptions = [
'alert',
'badge',
'sound',
'carPlay',
'criticalAlert',
'provisional',
'providesAppSettings',
];
const notificationSettings = {
alert: true,
badge: true,
sound: true,
carPlay: true,
criticalAlert: true,
provisional: true,
providesAppSettings: true,
lockScreen: true,
notificationCenter: true,
};
export const checkNotifications = jest.fn(async () => ({
status: RESULTS.GRANTED,
settings: notificationSettings,
}));
export const requestNotifications = jest.fn(async (options) => ({
status: RESULTS.GRANTED,
settings: options
.filter((option) => notificationOptions.includes(option))
.reduce((acc, option) => ({...acc, [option]: true}), {
lockScreen: true,
notificationCenter: true,
}),
}));
export const checkMultiple = jest.fn(async (permissions) =>
permissions.reduce((acc, permission) => ({...acc, [permission]: RESULTS.GRANTED}), {}),
);
export const requestMultiple = jest.fn(async (permissions) =>
permissions.reduce((acc, permission) => ({...acc, [permission]: RESULTS.GRANTED}), {}),
);
export default {
PERMISSIONS,
RESULTS,
check,
checkLocationAccuracy,
checkMultiple,
checkNotifications,
openLimitedPhotoLibraryPicker,
openSettings,
request,
requestLocationAccuracy,
requestMultiple,
requestNotifications,
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/UnPourTous/react-native-permissions.git
git@gitee.com:UnPourTous/react-native-permissions.git
UnPourTous
react-native-permissions
react-native-permissions
master

搜索帮助