import { describe, expect, it } from 'vitest';
import { normalizePermissionState, resolveStorageStatus } from './devicePermissions';

describe('normalizePermissionState', () => {
  it('maps default to prompt', () => {
    expect(normalizePermissionState('default')).toBe('prompt');
  });

  it('maps undefined to unsupported', () => {
    expect(normalizePermissionState(undefined)).toBe('unsupported');
  });

  it('passes through granted', () => {
    expect(normalizePermissionState('granted')).toBe('granted');
  });

  it('passes through denied', () => {
    expect(normalizePermissionState('denied')).toBe('denied');
  });
});

describe('resolveStorageStatus', () => {
  it('returns unsupported when not supported', () => {
    expect(resolveStorageStatus(null, false)).toBe('unsupported');
  });

  it('returns persisted when granted', () => {
    expect(resolveStorageStatus(true, true)).toBe('persisted');
  });

  it('returns available when supported but not persisted', () => {
    expect(resolveStorageStatus(false, true)).toBe('available');
  });
});
