This commit is contained in:
Kevin L'Hereec committed 2026-06-08 16:54:37 +02:00
1 parent 44f7d9acfc
commit ec7e66555d
4 files changed
+100 -4

No files matched your search

+64
View File
@@ -226,3 +226,67 @@ describe('Device', () => {
expect(d.getParameter('Device.X')!.value).toBe('new')
})
})
describe('Device.reclassifyInformWritables', () => {
it('promotes ProvisioningCode from property to parameter', () => {
const d = makeDevice()
// Simulate what updateFromValues does on Inform: stores as property (unknown writability)
d.setProperty(new DeviceProperty('InternetGatewayDevice.DeviceInfo.ProvisioningCode', 'abc'))
d.reclassifyInformWritables([
{ Name: 'InternetGatewayDevice.DeviceInfo.ProvisioningCode', Value: { _: 'abc' } },
])
expect(d.getParameter('InternetGatewayDevice.DeviceInfo.ProvisioningCode')).not.toBeNull()
expect(d.getProperty('InternetGatewayDevice.DeviceInfo.ProvisioningCode')).toBeNull()
})
it('promotes ParameterKey from property to parameter', () => {
const d = makeDevice()
d.setProperty(new DeviceProperty('InternetGatewayDevice.ManagementServer.ParameterKey', ''))
d.reclassifyInformWritables([
{ Name: 'InternetGatewayDevice.ManagementServer.ParameterKey', Value: { _: '' } },
])
expect(d.getParameter('InternetGatewayDevice.ManagementServer.ParameterKey')).not.toBeNull()
expect(d.getProperty('InternetGatewayDevice.ManagementServer.ParameterKey')).toBeNull()
})
it('does not touch params that are already parameters', () => {
const d = makeDevice()
d.setParameter(new DeviceParameter('Device.DeviceInfo.ProvisioningCode', 'existing'))
d.reclassifyInformWritables([
{ Name: 'Device.DeviceInfo.ProvisioningCode', Value: { _: 'existing' } },
])
expect(d.getParameter('Device.DeviceInfo.ProvisioningCode')!.value).toBe('existing')
expect(d.getProperty('Device.DeviceInfo.ProvisioningCode')).toBeNull()
})
it('does not reclassify unknown names (e.g. SoftwareVersion stays property)', () => {
const d = makeDevice()
d.setProperty(new DeviceProperty('InternetGatewayDevice.DeviceInfo.SoftwareVersion', 'v1'))
d.reclassifyInformWritables([
{ Name: 'InternetGatewayDevice.DeviceInfo.SoftwareVersion', Value: { _: 'v1' } },
])
// SoftwareVersion is NOT in the writable list — should stay as property
expect(d.getProperty('InternetGatewayDevice.DeviceInfo.SoftwareVersion')).not.toBeNull()
expect(d.getParameter('InternetGatewayDevice.DeviceInfo.SoftwareVersion')).toBeNull()
})
it('handles Name as object node (XMLParser artefact)', () => {
const d = makeDevice()
d.setProperty(new DeviceProperty('Device.DeviceInfo.ProvisioningCode', 'code'))
d.reclassifyInformWritables([
{ Name: { _: 'Device.DeviceInfo.ProvisioningCode' }, Value: { _: 'code' } },
])
expect(d.getParameter('Device.DeviceInfo.ProvisioningCode')).not.toBeNull()
expect(d.getProperty('Device.DeviceInfo.ProvisioningCode')).toBeNull()
})
})