|
1 | | -import {IfcPV, IfcPVWSMessage, instListEntry} from "@/app/types"; |
| 1 | +import { IfcPV, IfcPVWSMessage, instListEntry } from "@/app/types"; |
2 | 2 | import { |
3 | 3 | findPVByAddress, |
4 | 4 | findPVByHumanReadableName, |
5 | | - ExponentialOnThresholdFormat, getPrefix, getPvValue, |
| 5 | + ExponentialOnThresholdFormat, |
| 6 | + getPrefix, |
| 7 | + getPvValue, |
6 | 8 | } from "@/app/components/PVutils"; |
7 | 9 |
|
8 | 10 | 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 |
160 | 162 | }); |
161 | 163 |
|
162 | 164 | 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 | + ]; |
166 | 177 | expect(getPrefix(instList, myInstName)).toEqual(myInstPrefix); |
167 | | -}) |
| 178 | +}); |
168 | 179 |
|
169 | 180 | 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> = []; |
173 | 184 |
|
174 | 185 | expect(getPrefix(instList, myInstName)).toEqual(myInstPrefix); |
175 | | -}) |
| 186 | +}); |
176 | 187 |
|
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" }; |
179 | 190 | const result = getPvValue(updatedPV); |
180 | | - expect(result).toBe('Hello World'); |
| 191 | + expect(result).toBe("Hello World"); |
181 | 192 | }); |
182 | 193 |
|
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' |
185 | 196 | const result = getPvValue(updatedPV); |
186 | | - expect(result).toBe('Hello World'); |
| 197 | + expect(result).toBe("Hello World"); |
187 | 198 | }); |
188 | 199 |
|
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 }; |
191 | 202 | const result = getPvValue(updatedPV); |
192 | 203 | expect(result).toBe(123); |
193 | 204 | }); |
194 | 205 |
|
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" }; |
197 | 208 | const result = getPvValue(updatedPV); |
198 | 209 | expect(result).toBeUndefined(); |
199 | 210 | }); |
200 | 211 |
|
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: "" }; |
203 | 214 | const result = getPvValue(updatedPV); |
204 | | - expect(result).toBe(''); |
| 215 | + expect(result).toBe(""); |
205 | 216 | }); |
0 commit comments