File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { expect , describe , it } from "vitest" ;
2
- import { DdsLineRange , DisplayFile } from "../ui/dspf" ;
2
+ import { DdsLineRange , DisplayFile , FieldInfo } from "../ui/dspf" ;
3
3
4
4
describe ( 'DisplayFile tests' , ( ) => {
5
5
@@ -59,6 +59,43 @@ describe('DisplayFile tests', () => {
59
59
60
60
} ) ;
61
61
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
+
62
99
it ( 'No duplicate RecordInfo' , ( ) => {
63
100
let dds = new DisplayFile ( ) ;
64
101
dds . parse ( dspf1 ) ;
Original file line number Diff line number Diff line change @@ -351,7 +351,6 @@ export class DisplayFile {
351
351
return result ;
352
352
}
353
353
354
- // TODO: test cases
355
354
public static getLinesForField ( field : FieldInfo ) : string [ ] {
356
355
const newLines : string [ ] = [ ] ;
357
356
@@ -391,7 +390,6 @@ export class DisplayFile {
391
390
return newLines ;
392
391
}
393
392
394
- // TODO: test cases
395
393
public getRangeForField ( recordFormat : string , fieldName : string ) : DdsLineRange | undefined {
396
394
let range : DdsLineRange | undefined = undefined ;
397
395
const currentFormatI = this . formats . findIndex ( format => format . name === recordFormat ) ;
You can’t perform that action at this time.
0 commit comments