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"
8
+
9
+ let specificationMethods :ISpecificationMethods = {
10
+ getCurrentMessage :( ) => { return { type :0 , category : 0 } } ,
11
+ getMqttLanguageName :( ) => { return "english" } ,
12
+ getNonVariableNumberEntities :( ) => { return [ ] } ,
13
+ getMqttNames : ( ) => { return [ ] } ,
14
+ getSaveObservable :( ) => { return new Subject < void > ( ) } ,
15
+ postModbusEntity :( ) => { return new Subject < ImodbusData > ( ) } ,
16
+ postModbusWriteMqtt : ( ) => { return new Subject < string > ( ) } ,
17
+ hasDuplicateVariableConfigurations : ( ) => { return false } ,
18
+ canEditEntity : ( ) => { return true } ,
19
+ setEntitiesTouched :( ) => { } ,
20
+ addEntity :( ) => { } ,
21
+ deleteEntity :( ) => { } ,
22
+ copy2Translation :( ) => { }
23
+ } ;
24
+
25
+ let selectEntity :ImodbusEntity = {
26
+ id : 1 ,
27
+ modbusValue : [ 3 ] ,
28
+ mqttValue :"3" ,
29
+ identified :IdentifiedStates . identified ,
30
+ converter : { name :"select" , registerTypes :[ 3 , 4 ] } ,
31
+ readonly :false ,
32
+ registerType : 3 ,
33
+ modbusAddress : 4 ,
34
+ converterParameters : {
35
+
36
+ } as Iselect
37
+ }
38
+
39
+
40
+ describe ( 'Entity Component tests' , ( ) => {
41
+ beforeEach ( ( ) => {
42
+ cy . intercept ( "GET" , "**/converters" , {
43
+ fixture : "converters.json"
44
+ } )
45
+ // This configures the rootUrl for /api... calls
46
+ // they need to be relative in ingress scenarios,
47
+ // but they must be absolute for cypress tests
48
+ cy . window ( ) . then ( win => {
49
+ ( win as any ) . configuration = { rootUrl : "/" }
50
+ } )
51
+ } ) ;
52
+ it ( 'can mount' , ( ) => {
53
+
54
+ cy . mount ( EntityComponent , {
55
+ imports :[ NoopAnimationsModule ] ,
56
+ providers : [ provideHttpClient ( withInterceptorsFromDi ( ) ) , provideRouter ( [ ] ) ] ,
57
+ componentProperties : {
58
+ specificationMethods : specificationMethods ,
59
+ entity : selectEntity ,
60
+ disabled :false
61
+ }
62
+ } )
63
+ } )
64
+ } )
0 commit comments