@@ -15,7 +15,7 @@ import * as Events from '../src/controller/events';
15
15
import Request from '../src/controller/helpers/request' ;
16
16
import zclTransactionSequenceNumber from '../src/controller/helpers/zclTransactionSequenceNumber' ;
17
17
import ZclTransactionSequenceNumber from '../src/controller/helpers/zclTransactionSequenceNumber' ;
18
- import { Device , Group } from '../src/controller/model' ;
18
+ import { Device , Endpoint , Group } from '../src/controller/model' ;
19
19
import * as Models from '../src/models' ;
20
20
import { Wait } from '../src/utils' ;
21
21
import * as Utils from '../src/utils' ;
@@ -4037,6 +4037,18 @@ describe('Controller', () => {
4037
4037
expect ( mockAdapterSendZdo ) . toHaveBeenCalledTimes ( 8 ) ; // nodeDesc + activeEp + simpleDesc x1
4038
4038
} ) ;
4039
4039
4040
+ it ( 'Should remove disappeared endpoints on updateActiveEndpoints' , async ( ) => {
4041
+ await controller . start ( ) ;
4042
+ mockAdapterSendZdo . mockClear ( ) ;
4043
+ await mockAdapterEvents [ 'deviceJoined' ] ( { networkAddress : 129 , ieeeAddr : '0x129' } ) ;
4044
+
4045
+ const device = controller . getDeviceByIeeeAddr ( '0x129' ) ! ;
4046
+ device . endpoints . push ( Endpoint . create ( 2 , undefined , undefined , [ ] , [ ] , device . networkAddress , device . ieeeAddr ) ) ;
4047
+ expect ( device . endpoints . map ( ( e ) => e . ID ) ) . toStrictEqual ( [ 1 , 2 ] ) ;
4048
+ await device . updateActiveEndpoints ( ) ;
4049
+ expect ( device . endpoints . map ( ( e ) => e . ID ) ) . toStrictEqual ( [ 1 ] ) ;
4050
+ } ) ;
4051
+
4040
4052
it ( 'Receive zclData report from unkown attribute' , async ( ) => {
4041
4053
await controller . start ( ) ;
4042
4054
await mockAdapterEvents [ 'deviceJoined' ] ( { networkAddress : 129 , ieeeAddr : '0x129' } ) ;
0 commit comments