44 * SPDX-License-Identifier: Apache-2.0
55 */
66
7+ import { ClusterBehavior } from "#behavior/cluster/ClusterBehavior.js" ;
78import { DiscoveryError } from "#behavior/system/controller/discovery/DiscoveryError.js" ;
89import { NetworkClient } from "#behavior/system/network/NetworkClient.js" ;
910import { BasicInformationBehavior } from "#behaviors/basic-information" ;
@@ -15,7 +16,8 @@ import { AggregatorEndpoint } from "#endpoints/aggregator";
1516import { b$ , Crypto , deepCopy , MockCrypto , Seconds , Time , TimeoutError } from "#general" ;
1617import { Specification } from "#model" ;
1718import { ServerNode } from "#node/ServerNode.js" ;
18- import { ClientSubscription , FabricManager , SustainedSubscription } from "#protocol" ;
19+ import { ClientSubscription , FabricManager , SustainedSubscription , Val } from "#protocol" ;
20+ import { MyBehavior } from "../behavior/cluster/cluster-behavior-test-util.js" ;
1921import { MockSite } from "./mock-site.js" ;
2022
2123describe ( "ClientNode" , ( ) => {
@@ -402,6 +404,30 @@ describe("ClientNode", () => {
402404 await ep1 . commandsOf ( OnOffClient ) . offWithEffect ( { effectIdentifier : 0 , effectVariant : 0 } ) ;
403405 } ) ;
404406
407+ it . only ( "properly supports unknown clusters" , async ( ) => {
408+ // *** SETUP ***
409+
410+ await using site = new MockSite ( ) ;
411+ const { controller } = await site . addCommissionedPair ( {
412+ device : {
413+ type : ServerNode . RootEndpoint . with ( MyBehavior ) ,
414+ } ,
415+ } ) ;
416+ const peer = controller . peers . get ( "peer1" ) ! ;
417+
418+ // *** VERIFY STRUCTURE ***
419+
420+ const behavior = peer . behaviors . supported . cluster$1 ;
421+ expect ( typeof behavior ) . equals ( "function" ) ;
422+ expect ( ( behavior as ClusterBehavior . Type ) . schema . id ) . equals ( 1 ) ;
423+ expect ( ( behavior as ClusterBehavior . Type ) . cluster . id ) . equals ( 1 ) ;
424+
425+ const state = peer . maybeStateOf ( "cluster$1" ) ;
426+ expect ( typeof state ) . equals ( "object" ) ;
427+ expect ( ( state as Val . Struct ) [ 1 ] ) . equals ( "hello" ) ;
428+ expect ( ( state as Val . Struct ) . attr$1 ) . equals ( "hello" ) ;
429+ } ) ;
430+
405431 it ( "handles shutdown event and reestablishes connection" , ( ) => {
406432 // TODO
407433 } ) ;
0 commit comments