Skip to content

Commit 63390ea

Browse files
committed
Run pretty print(only)
1 parent c1e2479 commit 63390ea

File tree

12 files changed

+174
-139
lines changed

12 files changed

+174
-139
lines changed

cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { defineConfig } = require('cypress')
1+
const { defineConfig } = require("cypress");
22
module.exports = defineConfig({
33
component: {
44
devServer: {

cypress/Entity.cy.ts

+84-57
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,92 @@
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+
});

cypress/support/commands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
3535
// }
3636
// }
37-
// }
37+
// }

cypress/support/component.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
// ***********************************************************
1515

1616
// Import commands.js using ES2015 syntax:
17-
import './commands'
17+
import "./commands";
1818

19-
import { mount } from 'cypress/angular'
19+
import { mount } from "cypress/angular";
2020

2121
// Augment the Cypress namespace to include type definitions for
2222
// your custom command.
@@ -25,12 +25,12 @@ import { mount } from 'cypress/angular'
2525
declare global {
2626
namespace Cypress {
2727
interface Chainable {
28-
mount: typeof mount
28+
mount: typeof mount;
2929
}
3030
}
3131
}
3232

33-
Cypress.Commands.add('mount', mount)
33+
Cypress.Commands.add("mount", mount);
3434

3535
// Example use:
36-
// cy.mount(MyComponent)
36+
// cy.mount(MyComponent)

src/app/configure/configure.component.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ export class ConfigureComponent implements OnInit {
136136
);
137137
}
138138
if (config.debugComponents) {
139-
this.debugComponentsFormControl!.setValue(
140-
config.debugComponents
141-
);
139+
this.debugComponentsFormControl!.setValue(config.debugComponents);
142140
}
143141

144142
this.entityApiService.getSslFiles().subscribe((rc) => {
@@ -205,12 +203,12 @@ export class ConfigureComponent implements OnInit {
205203
this.ghPersonalAccessToken &&
206204
this.ghPersonalAccessToken.value.length > 0
207205
)
208-
this.config.githubPersonalToken = this.ghPersonalAccessToken.value;
206+
this.config.githubPersonalToken = this.ghPersonalAccessToken.value;
209207
if (
210208
this.debugComponentsFormControl &&
211209
this.debugComponentsFormControl.value.length > 0
212210
)
213-
this.config.debugComponents = this.debugComponentsFormControl.value;
211+
this.config.debugComponents = this.debugComponentsFormControl.value;
214212
this.entityApiService.postConfiguration(this.config).subscribe(() => {
215213
this.close();
216214
});

src/app/select-slave/select-slave.component.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,7 @@ export class SelectSlaveComponent extends SessionStorage implements OnInit {
192192
): IidentificationSpecification[] {
193193
let fc: FormControl = uiSlave.slaveForm.get(["ispecs"]) as FormControl;
194194
let slaveSpec = spec.find((s) => s.configuredSlave != undefined);
195-
if( slaveSpec )
196-
slave.specification = this.toSpecification(slaveSpec)
195+
if (slaveSpec) slave.specification = this.toSpecification(slaveSpec);
197196
let identifiedCount = 0;
198197
let ispec: IidentificationSpecification | null = null;
199198
if (detectSpec) {
@@ -307,7 +306,10 @@ export class SelectSlaveComponent extends SessionStorage implements OnInit {
307306
let ct = sl.getEntityCommandTopic(entity);
308307
return ct ? ct.commandTopic : "";
309308
}
310-
getModbusCommandTopic(uiSlave: IuiSlave, entity: Ientity): string | undefined {
309+
getModbusCommandTopic(
310+
uiSlave: IuiSlave,
311+
entity: Ientity,
312+
): string | undefined {
311313
let sl = new Slave(
312314
this.bus.busId,
313315
uiSlave.slave,

src/app/services/api-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { APP_BASE_HREF } from "@angular/common";
3535
})
3636
export class ApiService {
3737
converterCache: Iconverter[] | undefined = undefined;
38-
private rootUrl ="."
38+
private rootUrl = ".";
3939
constructor(
4040
private httpClient: HttpClient,
4141
private router: Router,
@@ -59,8 +59,8 @@ export class ApiService {
5959
alert(msg);
6060
}
6161
};
62-
if( (window as any).configuration && (window as any).configuration.rootUrl )
63-
this.rootUrl = (window as any).configuration.rootUrl
62+
if ((window as any).configuration && (window as any).configuration.rootUrl)
63+
this.rootUrl = (window as any).configuration.rootUrl;
6464
}
6565
private getFullUri(uri: apiUri): string {
6666
return this.rootUrl + uri;

src/app/services/specificationInterface.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ISpecificationMethods {
2525
): boolean;
2626
canEditEntity(): boolean;
2727
getMqttLanguageName(): string;
28-
getUom(entity_id:number): string;
28+
getUom(entity_id: number): string;
2929
addEntity(addedEntity: ImodbusEntityWithName): void;
3030
deleteEntity(entityId: number): void;
3131
copy2Translation(entity: Ientity): void;

src/app/specification/entity-value-control/entity-value-control.component.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class EntityValueControlComponent
5454
implements OnInit, OnDestroy, OnChanges
5555
{
5656
@Input({ required: true }) entity: ImodbusEntityWithName | undefined;
57-
@Input({ required: false }) uom: string ="";
57+
@Input({ required: false }) uom: string = "";
5858
@Input({ required: true }) specificationMethods: ISpecificationMethods;
5959
@Input()
6060
mqttValueObservable: Observable<ImodbusData | undefined>;
@@ -146,15 +146,14 @@ export class EntityValueControlComponent
146146
if (this.entity.mqttValue != undefined)
147147
this.numberFormControl.setValue(this.getMqttValue() as number);
148148
let num = this.entity.converterParameters as Inumber;
149-
if( num != undefined){
149+
if (num != undefined) {
150150
if (num.step) this.step = num.step;
151151
fc = this.numberFormControl;
152152
fc.clearValidators();
153153
if (num.identification != undefined && num.identification.min)
154154
fc.addValidators(Validators.min(num.identification.min));
155155
if (num.identification != undefined && num.identification.max)
156156
fc.addValidators(Validators.max(num.identification.max));
157-
158157
}
159158
break;
160159
case "select":
@@ -198,16 +197,15 @@ export class EntityValueControlComponent
198197
}
199198
});
200199
}
201-
getUom():string{
202-
return this.entity? this.specificationMethods.getUom( this.entity.id ):""
200+
getUom(): string {
201+
return this.entity ? this.specificationMethods.getUom(this.entity.id) : "";
203202
}
204-
203+
205204
getOptions(): IselectOption[] {
206205
if (this.entity) {
207206
let options = (this.entity.converterParameters as Iselect).options;
208207
if (options) return options;
209208
}
210209
return [];
211210
}
212-
213211
}

0 commit comments

Comments
 (0)