import type { Driver } from "../driver/Driver" ; import { createEmptyMockDriver } from "../test/mocks" ; import { BasicCCSet } from "./BasicCC" ; import { SupervisionCC , SupervisionCCReport , SupervisionStatus , } from "./SupervisionCC" ; const fakeDriver = createEmptyMockDriver ( ) as unknown as Driver ; describe ( "lib/commandclass/SupervisionCC => " , ( ) => { describe ( "responses should be detected correctly" , ( ) => { it ( "SupervisionCCGet should expect a response" , ( ) => { const ccRequest = SupervisionCC . encapsulate ( fakeDriver , new BasicCCSet ( fakeDriver , { nodeId : 2 , targetValue : 5 , } ) ) ; expect ( ccRequest . expectsCCResponse ( ) ) . toBeTrue ( ) ; } ) ; it ( "SupervisionCC/BasicCCSet => SupervisionCCReport (correct session ID) = expected" , ( ) => { const ccRequest = SupervisionCC . encapsulate ( fakeDriver , new BasicCCSet ( fakeDriver , { nodeId : 2 , targetValue : 5 , } ) ) ; const ccResponse = new SupervisionCCReport ( fakeDriver , { nodeId : 2 , moreUpdatesFollow : false , sessionId : ccRequest . sessionId , status : SupervisionStatus . Success , } ) ; expect ( ccRequest . isExpectedCCResponse ( ccResponse ) ) . toBeTrue ( ) ; } ) ; it ( "SupervisionCC/BasicCCSet => SupervisionCCReport (wrong session ID) = unexpected" , ( ) => { const ccRequest = SupervisionCC . encapsulate ( fakeDriver , new BasicCCSet ( fakeDriver , { nodeId : 2 , targetValue : 5 , } ) ) ; const ccResponse = new SupervisionCCReport ( fakeDriver , { nodeId : 2 , moreUpdatesFollow : false , sessionId : ccRequest . sessionId + 1 , status : SupervisionStatus . Success , } ) ; expect ( ccRequest . isExpectedCCResponse ( ccResponse ) ) . toBeFalse ( ) ; } ) ; } ) ; } ) ;