'use strict'; const { getInputType } = require('../src/input-types'); describe('getInputType', () => { test('known types return correct descriptor', () => { const ph = getInputType(6); expect(ph.haComponent).toBe('sensor'); expect(ph.unit).toBe('pH'); expect(ph.pollBucket).toBe('fast'); expect(ph.expression).toBeTruthy(); const moisture = getInputType(12); expect(moisture.haComponent).toBe('sensor'); expect(moisture.deviceClass).toBe('humidity'); expect(moisture.pollBucket).toBe('normal'); const rain = getInputType(2); expect(rain.haComponent).toBe('binary_sensor'); expect(rain.pollBucket).toBe('slow'); }); test('unknown type returns fallback sensor with _unknown flag', () => { const unknown = getInputType(999); expect(unknown.haComponent).toBe('sensor'); expect(unknown._unknown).toBe(true); expect(unknown.expression).toBeNull(); }); test('binary_sensor types have no unit', () => { expect(getInputType(21).unit).toBeNull(); expect(getInputType(149).unit).toBeNull(); }); });