- Device domain: updateFromValues, organizeParameters, identifier - BaseModel: full CRUD mock tests - DeviceModel: all methods mocked - Other models: collectionName verification - MainStateMachine: start, handleResponse, state transitions - ConfigurationEvaluationState: init, GPN flow, GPN-unsupported skip - MongodbProvider: getMongoDb guard - device_utils: hash determinism - vitest.config.ts: coverage scope (excludes HTTP layer) - 492 tests passing, 78% line coverage
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { getDeviceHashIdentifier } from '../../../app/utils/device_utils.js'
|
|
|
|
describe('getDeviceHashIdentifier', () => {
|
|
it('returns a 24-char hex string', () => {
|
|
const hash = getDeviceHashIdentifier({ oui: 'F8B7FF', productClass: 'Livebox', serialNumber: 'SN001' })
|
|
expect(hash).toHaveLength(24)
|
|
expect(hash).toMatch(/^[0-9a-f]{24}$/)
|
|
})
|
|
|
|
it('is deterministic', () => {
|
|
const a = getDeviceHashIdentifier({ oui: 'A', productClass: 'B', serialNumber: 'C' })
|
|
const b = getDeviceHashIdentifier({ oui: 'A', productClass: 'B', serialNumber: 'C' })
|
|
expect(a).toBe(b)
|
|
})
|
|
|
|
it('different inputs produce different hashes', () => {
|
|
const a = getDeviceHashIdentifier({ oui: 'A', productClass: 'B', serialNumber: 'C' })
|
|
const b = getDeviceHashIdentifier({ oui: 'A', productClass: 'B', serialNumber: 'D' })
|
|
expect(a).not.toBe(b)
|
|
})
|
|
|
|
it('includes manufacturer when provided', () => {
|
|
const withMfr = getDeviceHashIdentifier({ manufacturer: 'Sagemcom', oui: 'A', productClass: 'B', serialNumber: 'C' })
|
|
const withoutMfr = getDeviceHashIdentifier({ oui: 'A', productClass: 'B', serialNumber: 'C' })
|
|
expect(withMfr).not.toBe(withoutMfr)
|
|
})
|
|
})
|