import { describe, expect, it } from 'vitest'; import { areMobileRuntimePermissionsGranted, shouldPromptForNotificationPermission, shouldRequestMobileRuntimePermissions } from './mobile-runtime-permissions.rules'; describe('mobile-runtime-permissions.rules', () => { it('only requests runtime permissions on Capacitor shells', () => { expect(shouldRequestMobileRuntimePermissions('capacitor')).toBe(true); expect(shouldRequestMobileRuntimePermissions('browser')).toBe(false); expect(shouldRequestMobileRuntimePermissions('electron')).toBe(false); }); it('prompts for notification permissions until granted', () => { expect(shouldPromptForNotificationPermission('granted')).toBe(false); expect(shouldPromptForNotificationPermission('prompt')).toBe(true); expect(shouldPromptForNotificationPermission('denied')).toBe(true); }); it('requires every runtime permission alias to be granted', () => { expect(areMobileRuntimePermissionsGranted({ voiceGranted: true, cameraGranted: true, localNotificationsGranted: true, pushNotificationsGranted: true })).toBe(true); expect(areMobileRuntimePermissionsGranted({ voiceGranted: false, cameraGranted: true, localNotificationsGranted: true, pushNotificationsGranted: true })).toBe(false); }); });