import {
  describe,
  expect,
  it
} from 'vitest';

import { resolveDatabaseBackend } from './database-backend.rules';

describe('database-backend.rules', () => {
  it('routes Electron to the IPC SQLite backend', () => {
    expect(resolveDatabaseBackend({ isElectron: true, isCapacitor: false })).toBe('electron');
  });

  it('routes Capacitor native shells to SQLite instead of IndexedDB', () => {
    expect(resolveDatabaseBackend({ isElectron: false, isCapacitor: true })).toBe('capacitor-sqlite');
  });

  it('routes plain browser shells to IndexedDB', () => {
    expect(resolveDatabaseBackend({ isElectron: false, isCapacitor: false })).toBe('browser');
  });

  it('prefers Electron when both Electron and Capacitor flags are set', () => {
    expect(resolveDatabaseBackend({ isElectron: true, isCapacitor: true })).toBe('electron');
  });
});
