Skip to content

Commit 05eeea8

Browse files
committed
format
1 parent 5fb092a commit 05eeea8

File tree

2 files changed

+47
-32
lines changed

2 files changed

+47
-32
lines changed

app/components/Instrument.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {
55
getGroupsWithBlocksFromConfigOutput,
66
RC_ENABLE,
77
RC_INRANGE,
8-
SP_RBV, storePrecision,
8+
SP_RBV,
9+
storePrecision,
910
subscribeToBlockPVs,
1011
toPrecision,
1112
yesToBoolean,
@@ -15,7 +16,8 @@ import {
1516
DashboardArr,
1617
IfcBlock,
1718
IfcGroup,
18-
IfcPV, IfcPVWSMessage,
19+
IfcPV,
20+
IfcPVWSMessage,
1921
IfcPVWSRequest,
2022
PVWSRequestType,
2123
} from "@/app/types";
@@ -223,10 +225,12 @@ test("subscribeToBlockPVs subscribes to blocks, their run control and their SP:R
223225

224226
test("storePrecision adds precision to a block if it is the first update", () => {
225227
const precision = 3;
226-
const message: IfcPVWSMessage = {type:"update", pv:"",precision:precision}
227-
let blockWithoutPrecision: IfcBlock = {pvaddress:""}
228-
storePrecision(message, blockWithoutPrecision)
229-
expect(blockWithoutPrecision.precision).toEqual(precision)
230-
})
231-
232-
228+
const message: IfcPVWSMessage = {
229+
type: "update",
230+
pv: "",
231+
precision: precision,
232+
};
233+
let blockWithoutPrecision: IfcBlock = { pvaddress: "" };
234+
storePrecision(message, blockWithoutPrecision);
235+
expect(blockWithoutPrecision.precision).toEqual(precision);
236+
});

app/components/PVutils.test.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import {IfcPV, IfcPVWSMessage, instListEntry} from "@/app/types";
1+
import { IfcPV, IfcPVWSMessage, instListEntry } from "@/app/types";
22
import {
33
findPVByAddress,
44
findPVByHumanReadableName,
5-
ExponentialOnThresholdFormat, getPrefix, getPvValue,
5+
ExponentialOnThresholdFormat,
6+
getPrefix,
7+
getPvValue,
68
} from "@/app/components/PVutils";
79

810
test("findPVByAddress finds a PV and returns it", () => {
@@ -160,46 +162,55 @@ test("GIVEN value not a number when WHEN formatting THEN value is returned untou
160162
});
161163

162164
test("getPrefix returns an instrument prefix if instName is in instlist", () => {
163-
const myInstName = "BLAH"
164-
const myInstPrefix = `IN:${myInstName}:`
165-
const instList: Array<instListEntry> = [{name:myInstName, pvPrefix:myInstPrefix, isScheduled:true, seci:false, groups:[], hostName:myInstName}]
165+
const myInstName = "BLAH";
166+
const myInstPrefix = `IN:${myInstName}:`;
167+
const instList: Array<instListEntry> = [
168+
{
169+
name: myInstName,
170+
pvPrefix: myInstPrefix,
171+
isScheduled: true,
172+
seci: false,
173+
groups: [],
174+
hostName: myInstName,
175+
},
176+
];
166177
expect(getPrefix(instList, myInstName)).toEqual(myInstPrefix);
167-
})
178+
});
168179

169180
test("getPrefix returns TE if instrument prefix not in instlist", () => {
170-
const myInstName = "NDW9999"
171-
const myInstPrefix = `TE:${myInstName}:`
172-
const instList: Array<instListEntry> = []
181+
const myInstName = "NDW9999";
182+
const myInstPrefix = `TE:${myInstName}:`;
183+
const instList: Array<instListEntry> = [];
173184

174185
expect(getPrefix(instList, myInstName)).toEqual(myInstPrefix);
175-
})
186+
});
176187

177-
test('getPvValue returns the text value when text is provided', () => {
178-
const updatedPV = {type:"update", pv:"test", text: 'Hello World' };
188+
test("getPvValue returns the text value when text is provided", () => {
189+
const updatedPV = { type: "update", pv: "test", text: "Hello World" };
179190
const result = getPvValue(updatedPV);
180-
expect(result).toBe('Hello World');
191+
expect(result).toBe("Hello World");
181192
});
182193

183-
test('getPvValue decodes and return the base64 value when b64byt is provided', () => {
184-
const updatedPV = {type:"update", pv:"test", b64byt: 'SGVsbG8gV29ybGQ=' }; // Base64 for 'Hello World'
194+
test("getPvValue decodes and return the base64 value when b64byt is provided", () => {
195+
const updatedPV = { type: "update", pv: "test", b64byt: "SGVsbG8gV29ybGQ=" }; // Base64 for 'Hello World'
185196
const result = getPvValue(updatedPV);
186-
expect(result).toBe('Hello World');
197+
expect(result).toBe("Hello World");
187198
});
188199

189-
test('getPvValue returns the numeric value when value is provided', () => {
190-
const updatedPV = {type:"update", pv:"test", value: 123 };
200+
test("getPvValue returns the numeric value when value is provided", () => {
201+
const updatedPV = { type: "update", pv: "test", value: 123 };
191202
const result = getPvValue(updatedPV);
192203
expect(result).toBe(123);
193204
});
194205

195-
test('getPvValue returns undefined if no valid field is provided', () => {
196-
const updatedPV: IfcPVWSMessage = {type:"update", pv:"test",};
206+
test("getPvValue returns undefined if no valid field is provided", () => {
207+
const updatedPV: IfcPVWSMessage = { type: "update", pv: "test" };
197208
const result = getPvValue(updatedPV);
198209
expect(result).toBeUndefined();
199210
});
200211

201-
test('getPvValue handles an empty string for text', () => {
202-
const updatedPV = {type:"update", pv:"test", text: '' };
212+
test("getPvValue handles an empty string for text", () => {
213+
const updatedPV = { type: "update", pv: "test", text: "" };
203214
const result = getPvValue(updatedPV);
204-
expect(result).toBe('');
215+
expect(result).toBe("");
205216
});

0 commit comments

Comments
 (0)