import test from 'node:test'
import assert from 'node:assert/strict'

import {
  DEFAULT_CLOUDTENTACLES_DEVICE_ID,
  DEFAULT_CLOUDTENTACLES_DEVICE_TYPE,
  normalizeCloudtentaclesDeviceId,
  normalizeCloudtentaclesDeviceType,
} from './defaults.js'

test('normalizeCloudtentaclesDeviceId maps empty and legacy placeholder to default device', () => {
  assert.equal(normalizeCloudtentaclesDeviceId(''), DEFAULT_CLOUDTENTACLES_DEVICE_ID)
  assert.equal(normalizeCloudtentaclesDeviceId('-'), DEFAULT_CLOUDTENTACLES_DEVICE_ID)
  assert.equal(normalizeCloudtentaclesDeviceId(' custom-device '), 'custom-device')
})

test('normalizeCloudtentaclesDeviceType maps empty and legacy zero to default type', () => {
  assert.equal(normalizeCloudtentaclesDeviceType(undefined), DEFAULT_CLOUDTENTACLES_DEVICE_TYPE)
  assert.equal(normalizeCloudtentaclesDeviceType(0), DEFAULT_CLOUDTENTACLES_DEVICE_TYPE)
  assert.equal(normalizeCloudtentaclesDeviceType('2'), 2)
})
