test: 492 tests, 78% line coverage
- 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
This commit is contained in:
1 parent
ab21f11b30
commit
12a1787151
10 files changed
+710
-3
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user