Skip to content

Commit 71d9d02

Browse files
committed
New test getLinesForField
1 parent d2f60d5 commit 71d9d02

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/tests/dspf.test.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, describe, it } from "vitest";
2-
import { DdsLineRange, DisplayFile } from "../ui/dspf";
2+
import { DdsLineRange, DisplayFile, FieldInfo } from "../ui/dspf";
33

44
describe('DisplayFile tests', () => {
55

@@ -59,6 +59,43 @@ describe('DisplayFile tests', () => {
5959

6060
});
6161

62+
it('getLinesForField', () => {
63+
64+
let dds = new DisplayFile();
65+
66+
let field = new FieldInfo(0);
67+
field.displayType = `const`;
68+
field.value = `Some text`;
69+
field.position.x = 10;
70+
field.position.y = 4;
71+
72+
let lines = DisplayFile.getLinesForField(field);
73+
74+
expect(lines.length).toBe(1);
75+
expect(lines[0]).toBe(` A 4 10'Some text'`);
76+
77+
field.keywords.push(
78+
{
79+
name: "COLOR(BLU)",
80+
conditions: []
81+
},
82+
{
83+
name: "DSPATR(PR)",
84+
conditions: [{
85+
indicator: 21,
86+
negate: true
87+
}]
88+
}
89+
);
90+
91+
lines = DisplayFile.getLinesForField(field);
92+
expect(lines.length).toBe(3);
93+
expect(lines[0]).toBe(` A 4 10'Some text'`);
94+
expect(lines[1]).toBe(` A COLOR(BLU)`);
95+
expect(lines[2]).toBe(` A N21 DSPATR(PR)`);
96+
97+
});
98+
6299
it('No duplicate RecordInfo', () => {
63100
let dds = new DisplayFile();
64101
dds.parse(dspf1);

src/ui/dspf.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ export class DisplayFile {
351351
return result;
352352
}
353353

354-
// TODO: test cases
355354
public static getLinesForField(field: FieldInfo): string[] {
356355
const newLines: string[] = [];
357356

@@ -391,7 +390,6 @@ export class DisplayFile {
391390
return newLines;
392391
}
393392

394-
// TODO: test cases
395393
public getRangeForField(recordFormat: string, fieldName: string): DdsLineRange|undefined {
396394
let range: DdsLineRange|undefined = undefined;
397395
const currentFormatI = this.formats.findIndex(format => format.name === recordFormat);

0 commit comments

Comments
 (0)