import { expect, tap } from '@git.zone/tstest/tapbundle';
import { BluetoothLeTrackerConfigFlow } from '../../ts/integrations/bluetooth_le_tracker/index.js';

tap.test('builds static scanner config from a Bluetooth candidate', async () => {
  const flow = new BluetoothLeTrackerConfigFlow();
  const step = await flow.start({
    source: 'bluetooth',
    macAddress: 'AA:BB:CC:DD:EE:FF',
    name: 'Backpack Tag',
    metadata: {
      advertisement: { address: 'AA:BB:CC:DD:EE:FF', rssi: -64 },
    },
  }, {});
  const done = await step.submit!({
    trackNewDevices: false,
    trackBattery: true,
    scanIntervalSeconds: 12,
  });

  expect(done.kind).toEqual('done');
  expect(done.config?.knownDevices?.[0].address).toEqual('aa:bb:cc:dd:ee:ff');
  expect(done.config?.knownDevices?.[0].trackBattery).toBeTrue();
  expect(done.config?.trackNewDevices).toBeFalse();
});

export default tap.start();
