1- import { provideHttpClient , withInterceptorsFromDi } from "@angular/common/http"
2- import { NoopAnimationsModule } from "@angular/platform-browser/animations"
3- import { ActivatedRoute , provideRouter } from "@angular/router"
4- import { IdentifiedStates , ImodbusData , ImodbusEntity , Iselect } from "@modbus2mqtt/specification.shared"
5- import { ISpecificationMethods } from "angular/src/app/services/specificationInterface"
6- import { EntityComponent } from "angular/src/app/specification/entity/entity.component"
7- import { Subject } from "rxjs"
1+ import {
2+ provideHttpClient ,
3+ withInterceptorsFromDi ,
4+ } from "@angular/common/http" ;
5+ import { NoopAnimationsModule } from "@angular/platform-browser/animations" ;
6+ import { ActivatedRoute , provideRouter } from "@angular/router" ;
7+ import {
8+ IdentifiedStates ,
9+ ImodbusData ,
10+ ImodbusEntity ,
11+ Iselect ,
12+ } from "@modbus2mqtt/specification.shared" ;
13+ import { ISpecificationMethods } from "angular/src/app/services/specificationInterface" ;
14+ import { EntityComponent } from "angular/src/app/specification/entity/entity.component" ;
15+ import { Subject } from "rxjs" ;
816
9- let specificationMethods :ISpecificationMethods = {
10- getCurrentMessage :( ) => { return { type :0 , category : 0 } } ,
11- getMqttLanguageName :( ) => { return "english" } ,
12- getUom :( entity_id :number ) :string => { return "cm" } ,
13- getNonVariableNumberEntities :( ) => { return [ ] } ,
14- getMqttNames : ( ) => { return [ ] } ,
15- getSaveObservable :( ) => { return new Subject < void > ( ) } ,
16- postModbusEntity :( ) => { return new Subject < ImodbusData > ( ) } ,
17- postModbusWriteMqtt : ( ) => { return new Subject < string > ( ) } ,
18- hasDuplicateVariableConfigurations : ( ) => { return false } ,
19- canEditEntity : ( ) => { return true } ,
20- setEntitiesTouched :( ) => { } ,
21- addEntity :( ) => { } ,
22- deleteEntity :( ) => { } ,
23- copy2Translation :( ) => { }
17+ let specificationMethods : ISpecificationMethods = {
18+ getCurrentMessage : ( ) => {
19+ return { type : 0 , category : 0 } ;
20+ } ,
21+ getMqttLanguageName : ( ) => {
22+ return "english" ;
23+ } ,
24+ getUom : ( entity_id : number ) : string => {
25+ return "cm" ;
26+ } ,
27+ getNonVariableNumberEntities : ( ) => {
28+ return [ ] ;
29+ } ,
30+ getMqttNames : ( ) => {
31+ return [ ] ;
32+ } ,
33+ getSaveObservable : ( ) => {
34+ return new Subject < void > ( ) ;
35+ } ,
36+ postModbusEntity : ( ) => {
37+ return new Subject < ImodbusData > ( ) ;
38+ } ,
39+ postModbusWriteMqtt : ( ) => {
40+ return new Subject < string > ( ) ;
41+ } ,
42+ hasDuplicateVariableConfigurations : ( ) => {
43+ return false ;
44+ } ,
45+ canEditEntity : ( ) => {
46+ return true ;
47+ } ,
48+ setEntitiesTouched : ( ) => { } ,
49+ addEntity : ( ) => { } ,
50+ deleteEntity : ( ) => { } ,
51+ copy2Translation : ( ) => { } ,
2452} ;
2553
26- let selectEntity :ImodbusEntity = {
27- id : 1 ,
28- modbusValue : [ 3 ] ,
29- mqttValue :"3" ,
30- identified :IdentifiedStates . identified ,
31- converter : { name :"select" , registerTypes :[ 3 , 4 ] } ,
32- readonly :false ,
33- registerType : 3 ,
54+ let selectEntity : ImodbusEntity = {
55+ id : 1 ,
56+ modbusValue : [ 3 ] ,
57+ mqttValue : "3" ,
58+ identified : IdentifiedStates . identified ,
59+ converter : { name : "select" , registerTypes : [ 3 , 4 ] } ,
60+ readonly : false ,
61+ registerType : 3 ,
3462 modbusAddress : 4 ,
35- converterParameters : {
36-
37- } as Iselect
38- }
39-
63+ converterParameters : { } as Iselect ,
64+ } ;
4065
41- describe ( ' Entity Component tests' , ( ) => {
42- beforeEach ( ( ) => {
43- cy . intercept ( "GET" , "**/converters" , {
44- fixture : "converters.json"
45- } )
66+ describe ( " Entity Component tests" , ( ) => {
67+ beforeEach ( ( ) => {
68+ cy . intercept ( "GET" , "**/converters" , {
69+ fixture : "converters.json" ,
70+ } ) ;
4671 // This configures the rootUrl for /api... calls
4772 // they need to be relative in ingress scenarios,
4873 // but they must be absolute for cypress tests
49- cy . window ( ) . then ( win => {
50- ( win as any ) . configuration = { rootUrl : "/" }
51- } )
52- } ) ;
53- it ( 'can mount' , ( ) => {
54-
55- cy . mount ( EntityComponent , {
56- imports :[ NoopAnimationsModule ] ,
57- providers : [ provideHttpClient ( withInterceptorsFromDi ( ) ) , provideRouter ( [ ] ) ] ,
58- componentProperties : {
59- specificationMethods : specificationMethods ,
60- entity : selectEntity ,
61- disabled :false
62- }
63- } )
64- } )
65- } )
74+ cy . window ( ) . then ( ( win ) => {
75+ ( win as any ) . configuration = { rootUrl : "/" } ;
76+ } ) ;
77+ } ) ;
78+ it ( "can mount" , ( ) => {
79+ cy . mount ( EntityComponent , {
80+ imports : [ NoopAnimationsModule ] ,
81+ providers : [
82+ provideHttpClient ( withInterceptorsFromDi ( ) ) ,
83+ provideRouter ( [ ] ) ,
84+ ] ,
85+ componentProperties : {
86+ specificationMethods : specificationMethods ,
87+ entity : selectEntity ,
88+ disabled : false ,
89+ } ,
90+ } ) ;
91+ } ) ;
92+ } ) ;
0 commit comments