@design-core/core 0.0.7 → 50.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/DesignCoreQA.yml +3 -0
- package/core/designCore.js +1 -1
- package/core/dimensions/alignedDimension.js +7 -7
- package/core/dimensions/angularDimension.js +32 -32
- package/core/dimensions/{baseCircularDimension.js → circularDimensionBase.js} +19 -19
- package/core/dimensions/diametricDimension.js +10 -10
- package/core/dimensions/dimension.js +42 -42
- package/core/dimensions/{baseDimension.js → dimensionBase.js} +17 -17
- package/core/dimensions/{baseLinearDimension.js → linearDimensionBase.js} +9 -9
- package/core/dimensions/radialDimension.js +8 -8
- package/core/dimensions/rotatedDimension.js +8 -8
- package/core/entities/arc.js +22 -22
- package/core/entities/arctext.js +13 -13
- package/core/entities/circle.js +7 -7
- package/core/entities/hatch.js +28 -28
- package/core/entities/insert.js +5 -5
- package/core/entities/point.js +19 -19
- package/core/entities/polyline.js +3 -3
- package/core/entities/{basePolyline.js → polylineBase.js} +18 -18
- package/core/entities/text.js +4 -4
- package/core/lib/boundingBox.js +11 -11
- package/core/lib/canvas.js +6 -4
- package/core/lib/clipboard.js +2 -2
- package/core/lib/dxf/dxf.js +11 -11
- package/core/lib/dxf/dxfIterator.js +2 -2
- package/core/lib/entityManager.js +19 -19
- package/core/lib/inputManager.js +1 -1
- package/core/lib/matrix.js +1 -1
- package/core/lib/patterns.js +1 -1
- package/core/lib/polylineUtils.js +9 -9
- package/core/lib/renderers/cairoRenderer.js +5 -5
- package/core/lib/renderers/canvasRenderer.js +4 -4
- package/core/lib/renderers/pdfRenderer.js +7 -7
- package/core/lib/renderers/rendererBase.js +1 -1
- package/core/lib/scene.js +1 -1
- package/core/lib/selectionManager.js +18 -18
- package/core/lib/utils.js +5 -5
- package/core/properties/property.js +1 -1
- package/core/properties/propertyManager.js +37 -37
- package/core/tables/block.js +48 -46
- package/core/tables/dimStyle.js +5 -5
- package/core/tables/ltypeManager.js +1 -1
- package/core/tables/vport.js +2 -2
- package/core/tools/chamfer.js +6 -6
- package/core/tools/chamferFilletBase.js +4 -4
- package/core/tools/copy.js +8 -8
- package/core/tools/copybase.js +3 -3
- package/core/tools/copyclip.js +3 -3
- package/core/tools/cornerEntity.js +2 -2
- package/core/tools/cutclip.js +3 -3
- package/core/tools/explode.js +6 -6
- package/core/tools/extend.js +13 -13
- package/core/tools/fillet.js +6 -6
- package/core/tools/matchProp.js +1 -1
- package/core/tools/mirror.js +11 -11
- package/core/tools/move.js +5 -5
- package/core/tools/offset.js +29 -29
- package/core/tools/purge.js +10 -10
- package/core/tools/rotate.js +16 -16
- package/core/tools/scale.js +6 -6
- package/core/tools/trim.js +15 -15
- package/cspell.json +321 -0
- package/package.json +1 -1
- package/test/dimensions/alignedDimension.test.js +3 -3
- package/test/dimensions/angularDimension.test.js +7 -7
- package/test/dimensions/diametricDimension.test.js +9 -9
- package/test/dimensions/dimension.test.js +12 -12
- package/test/dimensions/{baseDimension.test.js → dimensionBase.test.js} +12 -12
- package/test/dimensions/{baseLinearDimension.test.js → linearDimensionBase.test.js} +7 -7
- package/test/dimensions/radialDimension.test.js +9 -9
- package/test/dimensions/rotatedDimension.test.js +4 -4
- package/test/entities/arc.test.js +10 -10
- package/test/entities/arctext.test.js +6 -6
- package/test/entities/circle.test.js +18 -18
- package/test/entities/hatch.test.js +39 -39
- package/test/entities/insert.test.js +9 -9
- package/test/entities/point.test.js +3 -3
- package/test/entities/{basePolyline.test.js → polylineBase.test.js} +131 -62
- package/test/entities/text.test.js +19 -19
- package/test/integration/exportIntegration.test.js +3 -3
- package/test/integration/userInputIntegration.test.js +5 -5
- package/test/lib/boundingBox.test.js +3 -3
- package/test/lib/canvas.test.js +9 -9
- package/test/lib/inputManager.test.js +4 -4
- package/test/lib/scene.test.js +9 -9
- package/test/lib/selectionManager.test.js +3 -3
- package/test/lib/snapping.test.js +1 -1
- package/test/properties/propertyManager.test.js +22 -22
- package/test/renderers/pdfRenderer.test.js +2 -2
- package/test/tables/block.test.js +63 -14
- package/test/tables/layerManager.test.js +2 -2
- package/test/test-helpers/hatchGridRenderer.js +3 -3
- package/test/test-helpers/test-helpers.js +6 -6
- package/test/tools/chamfer.test.js +60 -60
- package/test/tools/chamferFilletBase.test.js +36 -36
- package/test/tools/copy.test.js +6 -6
- package/test/tools/copybase.test.js +2 -2
- package/test/tools/copyclip.test.js +2 -2
- package/test/tools/cornerEntity.test.js +8 -8
- package/test/tools/cutclip.test.js +2 -2
- package/test/tools/erase.test.js +6 -6
- package/test/tools/explode.test.js +2 -2
- package/test/tools/extend.test.js +84 -84
- package/test/tools/fillet.test.js +62 -62
- package/test/tools/matchProp.test.js +6 -6
- package/test/tools/mirror.test.js +26 -26
- package/test/tools/move.test.js +7 -7
- package/test/tools/offset.test.js +65 -65
- package/test/tools/purge.test.js +4 -4
- package/test/tools/rotate.test.js +10 -10
- package/test/tools/scale.test.js +28 -28
- package/test/tools/trim.test.js +109 -109
- package/test/tools/zoom.test.js +5 -5
|
@@ -13,10 +13,10 @@ new Core();
|
|
|
13
13
|
|
|
14
14
|
const insert = new Insert({ handle: '1', points: [new Point()] });
|
|
15
15
|
const line = new Line({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
16
|
-
insert.block.
|
|
16
|
+
insert.block.addEntity(line);
|
|
17
17
|
|
|
18
18
|
const rotatedInsert = new Insert({ points: [new Point()], rotation: 45 });
|
|
19
|
-
rotatedInsert.block.
|
|
19
|
+
rotatedInsert.block.addEntity(line);
|
|
20
20
|
|
|
21
21
|
test('Test Insert.snaps', () => {
|
|
22
22
|
const point = new Point(100, 100);
|
|
@@ -51,7 +51,7 @@ test('Test Insert.boundingBox', () => {
|
|
|
51
51
|
expect(insert.boundingBox().yMax).toBeCloseTo(202);
|
|
52
52
|
|
|
53
53
|
const line2 = new Line({ points: [new Point(1001, 1002), new Point(2001, 2002)] });
|
|
54
|
-
insert.block.
|
|
54
|
+
insert.block.addEntity(line2);
|
|
55
55
|
|
|
56
56
|
expect(insert.boundingBox().xMin).toBeCloseTo(101);
|
|
57
57
|
expect(insert.boundingBox().xMax).toBeCloseTo(2001);
|
|
@@ -115,17 +115,17 @@ describe('Test Insert.draw', () => {
|
|
|
115
115
|
test('draw() returns the block items array', () => {
|
|
116
116
|
const ins = new Insert({ points: [new Point(0, 0)] });
|
|
117
117
|
const line = new Line({ points: [new Point(0, 0), new Point(1, 1)] });
|
|
118
|
-
ins.block.
|
|
118
|
+
ins.block.addEntity(line);
|
|
119
119
|
|
|
120
120
|
const result = ins.draw(makeMockCtx());
|
|
121
|
-
expect(result).toBe(ins.block.
|
|
121
|
+
expect(result).toBe(ins.block.entities);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
test('draw() returns empty array when block has no items', () => {
|
|
125
125
|
const ins = new Insert({ points: [new Point(0, 0)] });
|
|
126
126
|
const result = ins.draw(makeMockCtx());
|
|
127
127
|
expect(result).toEqual([]);
|
|
128
|
-
expect(result).toBe(ins.block.
|
|
128
|
+
expect(result).toBe(ins.block.entities);
|
|
129
129
|
});
|
|
130
130
|
|
|
131
131
|
test('draw() calls renderer.applyTransform with the insert point coordinates', () => {
|
|
@@ -159,9 +159,9 @@ describe('Test Insert.draw', () => {
|
|
|
159
159
|
test('draw() returns same items reference regardless of scale', () => {
|
|
160
160
|
const ins = new Insert({ points: [new Point(0, 0)] });
|
|
161
161
|
const line = new Line({ points: [new Point(0, 0), new Point(1, 1)] });
|
|
162
|
-
ins.block.
|
|
163
|
-
expect(ins.draw(makeMockCtx())).toBe(ins.block.
|
|
164
|
-
expect(ins.draw(makeMockCtx())).toBe(ins.block.
|
|
162
|
+
ins.block.addEntity(line);
|
|
163
|
+
expect(ins.draw(makeMockCtx())).toBe(ins.block.entities);
|
|
164
|
+
expect(ins.draw(makeMockCtx())).toBe(ins.block.entities);
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
|
|
@@ -701,7 +701,7 @@ test('Test Point.bulgeAngle', () => {
|
|
|
701
701
|
|
|
702
702
|
test('Test Point.bulgeRadius', () => {
|
|
703
703
|
// start point: 100,0
|
|
704
|
-
//
|
|
704
|
+
// centre: 100,50
|
|
705
705
|
// radius: 50
|
|
706
706
|
const point = new Point(100, 0);
|
|
707
707
|
|
|
@@ -771,7 +771,7 @@ test('Test Point.bulgeRadius', () => {
|
|
|
771
771
|
|
|
772
772
|
test('Test Point.apothem', () => {
|
|
773
773
|
// start point: 100,0
|
|
774
|
-
//
|
|
774
|
+
// centre: 100,50
|
|
775
775
|
// radius: 50
|
|
776
776
|
const point = new Point(100, 0);
|
|
777
777
|
|
|
@@ -829,7 +829,7 @@ test('Test Point.apothem', () => {
|
|
|
829
829
|
|
|
830
830
|
test('Test Point.bulgeCentrePoint', () => {
|
|
831
831
|
// start point: 100,0
|
|
832
|
-
//
|
|
832
|
+
// centre: 100,50
|
|
833
833
|
// radius: 50
|
|
834
834
|
const point = new Point(100, 0);
|
|
835
835
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PolylineBase } from '../../core/entities/polylineBase.js';
|
|
2
2
|
import { Point } from '../../core/entities/point';
|
|
3
3
|
import { Polyline } from '../../core/entities/polyline.js';
|
|
4
4
|
import { Line } from '../../core/entities/line.js';
|
|
@@ -30,7 +30,7 @@ test.each(inputScenarios)('Polyline.execute handles $desc', async (scenario) =>
|
|
|
30
30
|
const { inputs, expectedPoints } = scenario;
|
|
31
31
|
|
|
32
32
|
await withMockInput(DesignCore.Scene, inputs, async () => {
|
|
33
|
-
const polyline = new
|
|
33
|
+
const polyline = new PolylineBase({});
|
|
34
34
|
await polyline.execute();
|
|
35
35
|
|
|
36
36
|
expect(polyline.points.length).toBe(expectedPoints);
|
|
@@ -46,7 +46,7 @@ test.each(inputScenarios)('Polyline.execute handles $desc', async (scenario) =>
|
|
|
46
46
|
}, { extraMethods: { actionCommand: () => {} } });
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
-
test('Test
|
|
49
|
+
test('Test PolylineBase.draw calls renderer.drawShape with toPolylinePoints', () => {
|
|
50
50
|
const polyline = new Polyline({ points: [new Point(0, 0), new Point(10, 0), new Point(10, 5)] });
|
|
51
51
|
let capturedPoints;
|
|
52
52
|
const mockRenderer = {
|
|
@@ -58,11 +58,11 @@ test('Test BasePolyline.draw calls renderer.drawShape with toPolylinePoints', ()
|
|
|
58
58
|
expect(capturedPoints).toEqual(polyline.toPolylinePoints());
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test('Test
|
|
61
|
+
test('Test PolylineBase.getClosestSegment', () => {
|
|
62
62
|
// Polyline with a line and an arc segment
|
|
63
63
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10)];
|
|
64
64
|
points[1].bulge = 1; // Arc from (10,0) to (10,10)
|
|
65
|
-
const polyline = new
|
|
65
|
+
const polyline = new PolylineBase({ points });
|
|
66
66
|
|
|
67
67
|
// Closest to the line segment
|
|
68
68
|
const testPoint1 = new Point(5, 2);
|
|
@@ -77,11 +77,11 @@ test('Test BasePolyline.getClosestSegment', () => {
|
|
|
77
77
|
|
|
78
78
|
// ─── closing segment (closed polylines) ──────────────────────────────────────
|
|
79
79
|
|
|
80
|
-
test('
|
|
80
|
+
test('PolylineBase.getClosestSegmentIndex returns closing-segment index for closed polyline', () => {
|
|
81
81
|
// Square: P0=(0,0) P1=(10,0) P2=(10,10) P3=(0,10), closed flag set.
|
|
82
82
|
// Closing segment is P3→P0. A point near the left edge (0,5) is closest to that segment.
|
|
83
83
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
84
|
-
const poly = new
|
|
84
|
+
const poly = new PolylineBase({ points });
|
|
85
85
|
poly.flags.setFlagValue(1);
|
|
86
86
|
|
|
87
87
|
const closestIdx = poly.getClosestSegmentIndex(new Point(0, 5));
|
|
@@ -89,9 +89,9 @@ test('BasePolyline.getClosestSegmentIndex returns closing-segment index for clos
|
|
|
89
89
|
expect(closestIdx).toBe(4);
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
test('
|
|
92
|
+
test('PolylineBase.getClosestSegment returns closing segment as a Line for closed polyline', () => {
|
|
93
93
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
94
|
-
const poly = new
|
|
94
|
+
const poly = new PolylineBase({ points });
|
|
95
95
|
poly.flags.setFlagValue(1);
|
|
96
96
|
|
|
97
97
|
const seg = poly.getClosestSegment(new Point(0, 5));
|
|
@@ -103,21 +103,21 @@ test('BasePolyline.getClosestSegment returns closing segment as a Line for close
|
|
|
103
103
|
expect(seg.points[1].y).toBeCloseTo(0);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
test('
|
|
106
|
+
test('PolylineBase.areConsecutiveSegments returns false for non-adjacent segments on a closed polyline', () => {
|
|
107
107
|
// 4-point closed poly: segments 1 and 3 are NOT adjacent (bug: old code returned true).
|
|
108
108
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
109
|
-
const poly = new
|
|
109
|
+
const poly = new PolylineBase({ points });
|
|
110
110
|
poly.flags.setFlagValue(1);
|
|
111
111
|
|
|
112
112
|
expect(poly.areConsecutiveSegments(1, 3)).toBe(false);
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
test('
|
|
115
|
+
test('PolylineBase.areConsecutiveSegments returns true for closing segment and its neighbours', () => {
|
|
116
116
|
// 4-point closed poly, N=4 (closing segment index).
|
|
117
117
|
// Seg N-1=3 ends at P3, closing seg starts at P3 → consecutive (diff=1).
|
|
118
118
|
// Closing seg ends at P0, seg 1 starts at P0 → consecutive (wrap case).
|
|
119
119
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
120
|
-
const poly = new
|
|
120
|
+
const poly = new PolylineBase({ points });
|
|
121
121
|
poly.flags.setFlagValue(1);
|
|
122
122
|
|
|
123
123
|
expect(poly.areConsecutiveSegments(3, 4)).toBe(true); // diff = 1
|
|
@@ -125,11 +125,11 @@ test('BasePolyline.areConsecutiveSegments returns true for closing segment and i
|
|
|
125
125
|
expect(poly.areConsecutiveSegments(1, 4)).toBe(true); // wrap (order reversed)
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
test('
|
|
128
|
+
test('PolylineBase.closestPointOnSegment handles closing-segment index correctly', () => {
|
|
129
129
|
// 4-point square, closing segment = P3=(0,10)→P0=(0,0). Index = 4.
|
|
130
130
|
// Closest point on that segment to (0, 5) should be (0, 5).
|
|
131
131
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
132
|
-
const poly = new
|
|
132
|
+
const poly = new PolylineBase({ points });
|
|
133
133
|
poly.flags.setFlagValue(1);
|
|
134
134
|
|
|
135
135
|
const closest = poly.closestPointOnSegment(new Point(0, 5), 4);
|
|
@@ -138,9 +138,9 @@ test('BasePolyline.closestPointOnSegment handles closing-segment index correctly
|
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
|
|
141
|
-
test('Test
|
|
141
|
+
test('Test PolylineBase.closestPoint', () => {
|
|
142
142
|
const points = [new Point(100, 100), new Point(200, 100, -1), new Point(200, 50)];
|
|
143
|
-
const polyline = new
|
|
143
|
+
const polyline = new PolylineBase({ points: points });
|
|
144
144
|
// line segment
|
|
145
145
|
const point1 = new Point(150, 85);
|
|
146
146
|
const closest1 = polyline.closestPoint(point1);
|
|
@@ -156,14 +156,14 @@ test('Test BasePolyline.closestPoint', () => {
|
|
|
156
156
|
expect(closest2[1]).toBeCloseTo(10.857);
|
|
157
157
|
});
|
|
158
158
|
|
|
159
|
-
test('Test
|
|
160
|
-
let polyline = new
|
|
159
|
+
test('Test PolylineBase.boundingBox', () => {
|
|
160
|
+
let polyline = new PolylineBase({ points: [new Point(101, 102), new Point(201, 202)] });
|
|
161
161
|
expect(polyline.boundingBox().xMin).toBeCloseTo(101);
|
|
162
162
|
expect(polyline.boundingBox().xMax).toBeCloseTo(201);
|
|
163
163
|
expect(polyline.boundingBox().yMin).toBeCloseTo(102);
|
|
164
164
|
expect(polyline.boundingBox().yMax).toBeCloseTo(202);
|
|
165
165
|
|
|
166
|
-
polyline = new
|
|
166
|
+
polyline = new PolylineBase({ points: [new Point(101, 102), new Point(-201, 202)] });
|
|
167
167
|
expect(polyline.boundingBox().xMin).toBeCloseTo(-201);
|
|
168
168
|
expect(polyline.boundingBox().xMax).toBeCloseTo(101);
|
|
169
169
|
expect(polyline.boundingBox().yMin).toBeCloseTo(102);
|
|
@@ -173,7 +173,7 @@ test('Test BasePolyline.boundingBox', () => {
|
|
|
173
173
|
let points = [new Point(101, 102), new Point(200, 102), new Point(200, 0)];
|
|
174
174
|
// set the bulge
|
|
175
175
|
points[1].bulge = -1;
|
|
176
|
-
polyline = new
|
|
176
|
+
polyline = new PolylineBase({ points: points });
|
|
177
177
|
expect(polyline.boundingBox().xMin).toBeCloseTo(101);
|
|
178
178
|
expect(polyline.boundingBox().xMax).toBeCloseTo(251);
|
|
179
179
|
expect(polyline.boundingBox().yMin).toBeCloseTo(0);
|
|
@@ -182,19 +182,19 @@ test('Test BasePolyline.boundingBox', () => {
|
|
|
182
182
|
points = [new Point(101, 102), new Point(200, 102), new Point(200, 0)];
|
|
183
183
|
// set the bulge
|
|
184
184
|
points[1].bulge = -1;
|
|
185
|
-
polyline = new
|
|
185
|
+
polyline = new PolylineBase({ points: points });
|
|
186
186
|
expect(polyline.boundingBox().xMin).toBeCloseTo(101);
|
|
187
187
|
expect(polyline.boundingBox().xMax).toBeCloseTo(251);
|
|
188
188
|
expect(polyline.boundingBox().yMin).toBeCloseTo(0);
|
|
189
189
|
expect(polyline.boundingBox().yMax).toBeCloseTo(102);
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
test('Test
|
|
192
|
+
test('Test PolylineBase.getBulgeFromSegment', () => {
|
|
193
193
|
// start point: 100,0
|
|
194
|
-
//
|
|
194
|
+
// centre: 100,50
|
|
195
195
|
// radius: 50
|
|
196
196
|
const points = [new Point(), new Point(100, 0)];
|
|
197
|
-
const polyline = new
|
|
197
|
+
const polyline = new PolylineBase({ points: points });
|
|
198
198
|
|
|
199
199
|
// zero delta angle:
|
|
200
200
|
// bulge: 0
|
|
@@ -431,10 +431,10 @@ SEQEND
|
|
|
431
431
|
expect(file.contents).toEqual(dxfString);
|
|
432
432
|
});
|
|
433
433
|
|
|
434
|
-
test('Test
|
|
434
|
+
test('Test PolylineBase.toPolylinePoints', () => {
|
|
435
435
|
const points = [new Point(100, 100), new Point(200, 100), new Point(200, 50)];
|
|
436
436
|
points[1].bulge = -1;
|
|
437
|
-
const polyline = new
|
|
437
|
+
const polyline = new PolylineBase({ points: points });
|
|
438
438
|
|
|
439
439
|
const polylinePoints = polyline.toPolylinePoints();
|
|
440
440
|
expect(polylinePoints[0].x).toBe(100);
|
|
@@ -450,10 +450,10 @@ test('Test BasePolyline.toPolylinePoints', () => {
|
|
|
450
450
|
expect(polylinePoints[2].bulge).toBe(0);
|
|
451
451
|
});
|
|
452
452
|
|
|
453
|
-
test('Test
|
|
453
|
+
test('Test PolylineBase.toPolylinePoints returns defensive copy for open polyline', () => {
|
|
454
454
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10)];
|
|
455
455
|
points[1].bulge = -1;
|
|
456
|
-
const polyline = new
|
|
456
|
+
const polyline = new PolylineBase({ points: points });
|
|
457
457
|
|
|
458
458
|
const result = polyline.toPolylinePoints();
|
|
459
459
|
// Mutate the returned array and one of the returned points
|
|
@@ -466,13 +466,13 @@ test('Test BasePolyline.toPolylinePoints returns defensive copy for open polylin
|
|
|
466
466
|
expect(polyline.points[1].bulge).toBe(-1);
|
|
467
467
|
});
|
|
468
468
|
|
|
469
|
-
test('Test
|
|
469
|
+
test('Test PolylineBase.toPolylinePoints closed polyline appends closure point', () => {
|
|
470
470
|
// A triangle closed via the Close command (flag bit 1 set, no duplicate
|
|
471
471
|
// point stored in this.points).
|
|
472
472
|
const points = [new Point(0, 0), new Point(10, 0), new Point(5, 10)];
|
|
473
473
|
const flags = new Flags();
|
|
474
474
|
flags.addValue(1); // closed flag
|
|
475
|
-
const polyline = new
|
|
475
|
+
const polyline = new PolylineBase({ points: points, flags: flags });
|
|
476
476
|
|
|
477
477
|
const polylinePoints = polyline.toPolylinePoints();
|
|
478
478
|
// Should have 4 points: the 3 vertices plus the closure point
|
|
@@ -506,7 +506,7 @@ test('Polyline.execute handles Close option', async () => {
|
|
|
506
506
|
test('Polyline.execute supports Undo in line mode', async () => {
|
|
507
507
|
const inputs = [new Point(0, 0), new Point(10, 0), new Point(20, 0), 'Undo', new Point(10, 10), 'Close'];
|
|
508
508
|
await withMockInput(DesignCore.Scene, inputs, async () => {
|
|
509
|
-
const polyline = new
|
|
509
|
+
const polyline = new PolylineBase({});
|
|
510
510
|
await polyline.execute();
|
|
511
511
|
expect(polyline.points.length).toBe(3);
|
|
512
512
|
expect(polyline.points[0]).toEqual(inputs[0]);
|
|
@@ -519,7 +519,7 @@ test('Polyline.execute supports Undo in line mode', async () => {
|
|
|
519
519
|
test('Polyline.execute supports Undo in arc mode', async () => {
|
|
520
520
|
const inputs = [new Point(0, 0), new Point(10, 0), 'Arc', new Point(10, 10), new Point(20, 20), 'Undo', 'Line', new Point(10, 20), 'Close'];
|
|
521
521
|
await withMockInput(DesignCore.Scene, inputs, async () => {
|
|
522
|
-
const polyline = new
|
|
522
|
+
const polyline = new PolylineBase({});
|
|
523
523
|
await polyline.execute();
|
|
524
524
|
expect(polyline.points.length).toBe(4);
|
|
525
525
|
expect(polyline.points[0]).toEqual(inputs[0]);
|
|
@@ -537,7 +537,7 @@ test('Polyline.execute supports Undo in arc mode', async () => {
|
|
|
537
537
|
test('Polyline.execute supports Arc/Line mode switching', async () => {
|
|
538
538
|
const inputs = [new Point(0, 0), new Point(10, 0), 'Arc', new Point(10, 10), 'Line', new Point(20, 10), 'Close'];
|
|
539
539
|
await withMockInput(DesignCore.Scene, inputs, async () => {
|
|
540
|
-
const polyline = new
|
|
540
|
+
const polyline = new PolylineBase({});
|
|
541
541
|
await polyline.execute();
|
|
542
542
|
expect(polyline.points.length).toBe(4);
|
|
543
543
|
expect(polyline.points[0]).toEqual(inputs[0]);
|
|
@@ -553,29 +553,29 @@ test('Polyline.execute supports Arc/Line mode switching', async () => {
|
|
|
553
553
|
|
|
554
554
|
// ─── Auto-close when first and last point are the same ───────────────────────
|
|
555
555
|
|
|
556
|
-
test('
|
|
556
|
+
test('PolylineBase constructor auto-closes when last point matches first', () => {
|
|
557
557
|
// Simulate a polyline loaded with a redundant closing point (e.g. from DXF data)
|
|
558
558
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 0)];
|
|
559
|
-
const polyline = new
|
|
559
|
+
const polyline = new PolylineBase({ points });
|
|
560
560
|
|
|
561
561
|
// Duplicate point should be removed and the closed flag set
|
|
562
562
|
expect(polyline.points.length).toBe(3);
|
|
563
563
|
expect(polyline.flags.hasFlag(1)).toBe(true);
|
|
564
564
|
});
|
|
565
565
|
|
|
566
|
-
test('
|
|
566
|
+
test('PolylineBase constructor does not auto-close when fewer than 3 unique points remain after pop', () => {
|
|
567
567
|
// [A, B, A] — only 2 unique points after removing the duplicate; must not auto-close
|
|
568
568
|
const points = [new Point(0, 0), new Point(10, 0), new Point(0, 0)];
|
|
569
|
-
const polyline = new
|
|
569
|
+
const polyline = new PolylineBase({ points });
|
|
570
570
|
|
|
571
571
|
expect(polyline.points.length).toBe(3);
|
|
572
572
|
expect(polyline.flags.hasFlag(1)).toBe(false);
|
|
573
573
|
});
|
|
574
574
|
|
|
575
|
-
test('
|
|
575
|
+
test('PolylineBase constructor does not auto-close with only 2 identical points', () => {
|
|
576
576
|
// Only 2 unique points — not enough to form a closed polygon
|
|
577
577
|
const points = [new Point(0, 0), new Point(0, 0)];
|
|
578
|
-
const polyline = new
|
|
578
|
+
const polyline = new PolylineBase({ points });
|
|
579
579
|
|
|
580
580
|
expect(polyline.points.length).toBe(2);
|
|
581
581
|
expect(polyline.flags.hasFlag(1)).toBe(false);
|
|
@@ -593,14 +593,14 @@ test('Polyline.execute auto-closes when start point is re-entered', async () =>
|
|
|
593
593
|
// The constructor will have auto-closed the entity when pt4 == pt1
|
|
594
594
|
if (entity.points.length === 4 && entity.points.at(-1).isSame(pt1)) {
|
|
595
595
|
// simulate what the constructor does: a new entity created from this data would auto-close
|
|
596
|
-
const rebuilt = new
|
|
596
|
+
const rebuilt = new PolylineBase({ points: [...entity.points] });
|
|
597
597
|
if (rebuilt.flags.hasFlag(1)) autoClosedCount++;
|
|
598
598
|
}
|
|
599
599
|
return 0;
|
|
600
600
|
};
|
|
601
601
|
|
|
602
602
|
await withMockInput(DesignCore.Scene, [pt1, pt2, pt3, pt4], async () => {
|
|
603
|
-
const polyline = new
|
|
603
|
+
const polyline = new PolylineBase({});
|
|
604
604
|
await polyline.execute();
|
|
605
605
|
// execute does not exit early — the duplicate point is on the instance
|
|
606
606
|
expect(polyline.points.length).toBe(4);
|
|
@@ -609,10 +609,10 @@ test('Polyline.execute auto-closes when start point is re-entered', async () =>
|
|
|
609
609
|
}, { extraMethods: { actionCommand: mockActionCommand } });
|
|
610
610
|
});
|
|
611
611
|
|
|
612
|
-
test('
|
|
613
|
-
const poly = new
|
|
612
|
+
test('PolylineBase.fromPolylinePoints round-trip preserves open polyline', () => {
|
|
613
|
+
const poly = new PolylineBase({ points: [new Point(0, 0, 0.5), new Point(10, 0), new Point(10, 10)] });
|
|
614
614
|
const polyPts = poly.toPolylinePoints();
|
|
615
|
-
const rebuilt = new
|
|
615
|
+
const rebuilt = new PolylineBase({});
|
|
616
616
|
rebuilt.fromPolylinePoints(polyPts);
|
|
617
617
|
expect(rebuilt.points.length).toBe(3);
|
|
618
618
|
expect(rebuilt.points[0].x).toBe(0);
|
|
@@ -622,16 +622,16 @@ test('BasePolyline.fromPolylinePoints round-trip preserves open polyline', () =>
|
|
|
622
622
|
expect(rebuilt.points[2].y).toBe(10);
|
|
623
623
|
});
|
|
624
624
|
|
|
625
|
-
test('
|
|
625
|
+
test('PolylineBase.fromPolylinePoints round-trip strips closure point for closed polyline', () => {
|
|
626
626
|
const flags = new Flags();
|
|
627
627
|
flags.addValue(1);
|
|
628
|
-
const poly = new
|
|
628
|
+
const poly = new PolylineBase({ points: [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)], flags: flags });
|
|
629
629
|
const polyPts = poly.toPolylinePoints();
|
|
630
630
|
// toPolylinePoints appends a closure copy of the first point
|
|
631
631
|
expect(polyPts.length).toBe(5);
|
|
632
632
|
const flags2 = new Flags();
|
|
633
633
|
flags2.addValue(1);
|
|
634
|
-
const rebuilt = new
|
|
634
|
+
const rebuilt = new PolylineBase({ flags: flags2 });
|
|
635
635
|
rebuilt.fromPolylinePoints(polyPts);
|
|
636
636
|
expect(rebuilt.points.length).toBe(4);
|
|
637
637
|
expect(rebuilt.points[0].x).toBe(0);
|
|
@@ -641,12 +641,12 @@ test('BasePolyline.fromPolylinePoints round-trip strips closure point for closed
|
|
|
641
641
|
|
|
642
642
|
// ─── closestPoint: closed polyline closing segment ───────────────────────────
|
|
643
643
|
|
|
644
|
-
test('
|
|
644
|
+
test('PolylineBase.closestPoint finds closest point on closing segment of closed polyline', () => {
|
|
645
645
|
// Square: P0=(0,0), P1=(10,0), P2=(10,10), P3=(0,10), closed flag set.
|
|
646
646
|
// Closing segment is P3=(0,10) → P0=(0,0).
|
|
647
647
|
// A test point on the left edge (0, 5) must resolve to (0, 5) on the closing segment.
|
|
648
648
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
649
|
-
const poly = new
|
|
649
|
+
const poly = new PolylineBase({ points });
|
|
650
650
|
poly.flags.setFlagValue(1);
|
|
651
651
|
|
|
652
652
|
const [closest, dist] = poly.closestPoint(new Point(0, 5));
|
|
@@ -655,11 +655,11 @@ test('BasePolyline.closestPoint finds closest point on closing segment of closed
|
|
|
655
655
|
expect(dist).toBeCloseTo(0);
|
|
656
656
|
});
|
|
657
657
|
|
|
658
|
-
test('
|
|
658
|
+
test('PolylineBase.closestPoint closing segment is preferred over other segments', () => {
|
|
659
659
|
// The test point (-1, 5) is clearly nearest the closing segment (left edge),
|
|
660
660
|
// not the bottom, right, or top edges.
|
|
661
661
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
662
|
-
const poly = new
|
|
662
|
+
const poly = new PolylineBase({ points });
|
|
663
663
|
poly.flags.setFlagValue(1);
|
|
664
664
|
|
|
665
665
|
const [closest, dist] = poly.closestPoint(new Point(-1, 5));
|
|
@@ -668,14 +668,14 @@ test('BasePolyline.closestPoint closing segment is preferred over other segments
|
|
|
668
668
|
expect(dist).toBeCloseTo(1);
|
|
669
669
|
});
|
|
670
670
|
|
|
671
|
-
test('
|
|
671
|
+
test('PolylineBase.closestPoint for open polyline does not include closing segment', () => {
|
|
672
672
|
// For point (-1, 1) on the open square:
|
|
673
673
|
// – Nearest on seg P0→P1 (y=0): foot (-1,0) clips to (0,0), dist = √2 ≈ 1.41
|
|
674
674
|
// – Nearest on seg P2→P3 (y=10): foot (-1,10) clips to (0,10), dist ≈ 9.06
|
|
675
675
|
// – If the closing segment existed (x=0, y∈[0,10]): foot (0,1), dist = 1 ← closer!
|
|
676
676
|
// An open polyline must NOT check the closing segment, so it returns (0,0).
|
|
677
677
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
678
|
-
const poly = new
|
|
678
|
+
const poly = new PolylineBase({ points });
|
|
679
679
|
// flag NOT set — open polyline
|
|
680
680
|
|
|
681
681
|
const [closest] = poly.closestPoint(new Point(-1, 1));
|
|
@@ -683,11 +683,80 @@ test('BasePolyline.closestPoint for open polyline does not include closing segme
|
|
|
683
683
|
expect(closest.y).toBeCloseTo(0);
|
|
684
684
|
});
|
|
685
685
|
|
|
686
|
-
|
|
686
|
+
// ─── isPointOnSegment ────────────────────────────────────────────────────────
|
|
687
|
+
|
|
688
|
+
const lineSegmentCases = [
|
|
689
|
+
{ desc: 'midpoint', point: new Point(5, 0), expected: true },
|
|
690
|
+
{ desc: 'start endpoint', point: new Point(0, 0), expected: true },
|
|
691
|
+
{ desc: 'end endpoint', point: new Point(10, 0), expected: true },
|
|
692
|
+
{ desc: 'perpendicular off-line', point: new Point(5, 5), expected: false },
|
|
693
|
+
{ desc: 'collinear beyond end', point: new Point(15, 0), expected: false },
|
|
694
|
+
];
|
|
695
|
+
|
|
696
|
+
test.each(lineSegmentCases)('PolylineBase.isPointOnSegment line segment – $desc', ({ point, expected }) => {
|
|
697
|
+
const A = new Point(0, 0);
|
|
698
|
+
const B = new Point(10, 0);
|
|
699
|
+
const poly = new PolylineBase({ points: [A, B] });
|
|
700
|
+
expect(poly.isPointOnSegment(point, A, B)).toBe(expected);
|
|
701
|
+
});
|
|
702
|
+
|
|
703
|
+
// CCW 180° semicircle from (10,0) to (-10,0), bulge=1, centre=(0,0), radius=10.
|
|
704
|
+
// Arc spans angles [0°, 180°] — the upper semicircle.
|
|
705
|
+
const ccwArcCases = [
|
|
706
|
+
{ desc: 'arc midpoint (0,10) at 90°', point: new Point(0, 10), expected: true },
|
|
707
|
+
{ desc: 'start endpoint (10,0)', point: new Point(10, 0), expected: true },
|
|
708
|
+
{ desc: 'end endpoint (-10,0)', point: new Point(-10, 0), expected: true },
|
|
709
|
+
{ desc: 'lower semicircle (0,-10)', point: new Point(0, -10), expected: false },
|
|
710
|
+
];
|
|
711
|
+
|
|
712
|
+
test.each(ccwArcCases)('PolylineBase.isPointOnSegment CCW arc (bulge=1, 180°) – $desc', ({ point, expected }) => {
|
|
713
|
+
const A = new Point(10, 0);
|
|
714
|
+
A.bulge = 1;
|
|
715
|
+
const B = new Point(-10, 0);
|
|
716
|
+
const poly = new PolylineBase({ points: [A, B] });
|
|
717
|
+
expect(poly.isPointOnSegment(point, A, B)).toBe(expected);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// CW 180° semicircle from (10,0) to (-10,0), bulge=-1, centre=(0,0), radius=10.
|
|
721
|
+
// Arc spans angles ≤0° or ≥180° — the lower semicircle.
|
|
722
|
+
const cwArcCases = [
|
|
723
|
+
{ desc: 'arc midpoint (0,-10) at -90°', point: new Point(0, -10), expected: true },
|
|
724
|
+
{ desc: 'start endpoint (10,0)', point: new Point(10, 0), expected: true },
|
|
725
|
+
{ desc: 'end endpoint (-10,0)', point: new Point(-10, 0), expected: true },
|
|
726
|
+
{ desc: 'upper semicircle (0,10)', point: new Point(0, 10), expected: false },
|
|
727
|
+
];
|
|
728
|
+
|
|
729
|
+
test.each(cwArcCases)('PolylineBase.isPointOnSegment CW arc (bulge=-1, 180°) – $desc', ({ point, expected }) => {
|
|
730
|
+
const A = new Point(10, 0);
|
|
731
|
+
A.bulge = -1;
|
|
732
|
+
const B = new Point(-10, 0);
|
|
733
|
+
const poly = new PolylineBase({ points: [A, B] });
|
|
734
|
+
expect(poly.isPointOnSegment(point, A, B)).toBe(expected);
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
// CCW 180° arc from (0,10) to (0,-10), bulge=1, centre=(0,0), radius=10.
|
|
738
|
+
// startAngle=90° > endAngle=-90° so the check wraps: angles ≥90° OR ≤-90°.
|
|
739
|
+
// This covers the left semicircle (through (-10,0)).
|
|
740
|
+
const ccwArcWrapCases = [
|
|
741
|
+
{ desc: 'left midpoint (-10,0) at 180°', point: new Point(-10, 0), expected: true },
|
|
742
|
+
{ desc: 'start endpoint (0,10)', point: new Point(0, 10), expected: true },
|
|
743
|
+
{ desc: 'end endpoint (0,-10)', point: new Point(0, -10), expected: true },
|
|
744
|
+
{ desc: 'right side (10,0) at 0°', point: new Point(10, 0), expected: false },
|
|
745
|
+
];
|
|
746
|
+
|
|
747
|
+
test.each(ccwArcWrapCases)('PolylineBase.isPointOnSegment CCW arc wrapping past ±180° (bulge=1, startAngle=90° > endAngle=-90°) – $desc', ({ point, expected }) => {
|
|
748
|
+
const A = new Point(0, 10);
|
|
749
|
+
A.bulge = 1;
|
|
750
|
+
const B = new Point(0, -10);
|
|
751
|
+
const poly = new PolylineBase({ points: [A, B] });
|
|
752
|
+
expect(poly.isPointOnSegment(point, A, B)).toBe(expected);
|
|
753
|
+
});
|
|
754
|
+
|
|
755
|
+
test('PolylineBase.closestPoint is consistent with getClosestSegmentIndex for closed polyline', () => {
|
|
687
756
|
// For a closed square, both methods should agree that the closing segment
|
|
688
757
|
// is nearest for a point on the left edge.
|
|
689
758
|
const points = [new Point(0, 0), new Point(10, 0), new Point(10, 10), new Point(0, 10)];
|
|
690
|
-
const poly = new
|
|
759
|
+
const poly = new PolylineBase({ points });
|
|
691
760
|
poly.flags.setFlagValue(1);
|
|
692
761
|
|
|
693
762
|
const testPoint = new Point(-2, 5);
|
|
@@ -702,8 +771,8 @@ test('BasePolyline.closestPoint is consistent with getClosestSegmentIndex for cl
|
|
|
702
771
|
|
|
703
772
|
// ─── preview ─────────────────────────────────────────────────────────────────
|
|
704
773
|
|
|
705
|
-
test('
|
|
706
|
-
const poly = new
|
|
774
|
+
test('PolylineBase.preview - 0 points does nothing', () => {
|
|
775
|
+
const poly = new PolylineBase({});
|
|
707
776
|
DesignCore.Scene.auxiliaryEntities.clear();
|
|
708
777
|
DesignCore.Scene.previewEntities.clear();
|
|
709
778
|
|
|
@@ -712,8 +781,8 @@ test('BasePolyline.preview - 0 points does nothing', () => {
|
|
|
712
781
|
expect(DesignCore.Scene.previewEntities.count()).toBe(0);
|
|
713
782
|
});
|
|
714
783
|
|
|
715
|
-
test('
|
|
716
|
-
const poly = new
|
|
784
|
+
test('PolylineBase.preview - LINE mode creates temp entity', () => {
|
|
785
|
+
const poly = new PolylineBase({});
|
|
717
786
|
poly.points.push(new Point(0, 0));
|
|
718
787
|
|
|
719
788
|
const origCreate = DesignCore.Scene.previewEntities.create;
|
|
@@ -730,8 +799,8 @@ test('BasePolyline.preview - LINE mode creates temp entity', () => {
|
|
|
730
799
|
DesignCore.Scene.previewEntities.create = origCreate;
|
|
731
800
|
});
|
|
732
801
|
|
|
733
|
-
test('
|
|
734
|
-
const poly = new
|
|
802
|
+
test('PolylineBase.preview - ARC mode adds rubber band and creates arc temp entity', () => {
|
|
803
|
+
const poly = new PolylineBase({});
|
|
735
804
|
poly.points.push(new Point(0, 0));
|
|
736
805
|
poly.points.push(new Point(10, 0));
|
|
737
806
|
poly.inputMode = poly.modes.ARC;
|
|
@@ -114,9 +114,9 @@ test('Test Text.getTextFrameCorners', () => {
|
|
|
114
114
|
expect(corners[3].y).toBeCloseTo(100);
|
|
115
115
|
|
|
116
116
|
// Text frame calculation with text alignment
|
|
117
|
-
// bounding rect is 10x10, so with
|
|
117
|
+
// bounding rect is 10x10, so with centre/middle alignment the text frame should be offset by 5 in both x and y from the insertion point
|
|
118
118
|
const alignedText = new Text({ points: [new Point(100, 100)] });
|
|
119
|
-
alignedText.setProperty('horizontalAlignment', 1); //
|
|
119
|
+
alignedText.setProperty('horizontalAlignment', 1); // centre
|
|
120
120
|
corners = alignedText.getTextFrameCorners();
|
|
121
121
|
|
|
122
122
|
expect(corners[0].x).toBeCloseTo(95);
|
|
@@ -149,7 +149,7 @@ test('Test Text.getTextFrameCorners', () => {
|
|
|
149
149
|
expect(corners[3].y).toBeCloseTo(105);
|
|
150
150
|
|
|
151
151
|
|
|
152
|
-
// add rotation of 45 degrees to the
|
|
152
|
+
// add rotation of 45 degrees to the centre/middle aligned text and ensure the text frame corners are correctly calculated with both alignment and rotation applied
|
|
153
153
|
alignedText.setRotation(45);
|
|
154
154
|
corners = alignedText.getTextFrameCorners();
|
|
155
155
|
|
|
@@ -408,7 +408,7 @@ AcDbText
|
|
|
408
408
|
// and a second alignment point with groupcode 11,21,31 for the text insertion point
|
|
409
409
|
// bounding rect is 10x10, so second point should be at 100-(10*0.5), 200-(10*0.5) = 95, 195
|
|
410
410
|
|
|
411
|
-
const
|
|
411
|
+
const centredText = new Text({
|
|
412
412
|
handle: text.getProperty('handle'),
|
|
413
413
|
points: text.points,
|
|
414
414
|
string: text.getProperty('string'),
|
|
@@ -417,12 +417,12 @@ AcDbText
|
|
|
417
417
|
horizontalAlignment: text.getProperty('horizontalAlignment'),
|
|
418
418
|
verticalAlignment: text.getProperty('verticalAlignment'),
|
|
419
419
|
});
|
|
420
|
-
|
|
421
|
-
|
|
420
|
+
centredText.setProperty('horizontalAlignment', 1); // centre
|
|
421
|
+
centredText.setProperty('verticalAlignment', 2); // middle
|
|
422
422
|
file = new File();
|
|
423
|
-
|
|
423
|
+
centredText.dxf(file);
|
|
424
424
|
|
|
425
|
-
const
|
|
425
|
+
const dxfCentredString = `0
|
|
426
426
|
TEXT
|
|
427
427
|
5
|
|
428
428
|
1
|
|
@@ -459,21 +459,21 @@ AcDbText
|
|
|
459
459
|
73
|
|
460
460
|
2
|
|
461
461
|
`;
|
|
462
|
-
expect(file.contents).toEqual(
|
|
462
|
+
expect(file.contents).toEqual(dxfCentredString);
|
|
463
463
|
|
|
464
464
|
// create new entity from entity data to ensure all props are loaded
|
|
465
465
|
const importCenteredText = new Text({
|
|
466
|
-
handle:
|
|
467
|
-
points:
|
|
468
|
-
string:
|
|
469
|
-
height:
|
|
470
|
-
styleName:
|
|
471
|
-
horizontalAlignment:
|
|
472
|
-
verticalAlignment:
|
|
466
|
+
handle: centredText.getProperty('handle'),
|
|
467
|
+
points: centredText.points,
|
|
468
|
+
string: centredText.getProperty('string'),
|
|
469
|
+
height: centredText.getProperty('height'),
|
|
470
|
+
styleName: centredText.getProperty('styleName'),
|
|
471
|
+
horizontalAlignment: centredText.getProperty('horizontalAlignment'),
|
|
472
|
+
verticalAlignment: centredText.getProperty('verticalAlignment'),
|
|
473
473
|
});
|
|
474
474
|
file = new File();
|
|
475
475
|
importCenteredText.dxf(file);
|
|
476
|
-
expect(file.contents).toEqual(
|
|
476
|
+
expect(file.contents).toEqual(dxfCentredString);
|
|
477
477
|
});
|
|
478
478
|
|
|
479
479
|
test('Text constructor covers all property branches', () => {
|
|
@@ -522,13 +522,13 @@ test('Text getHorizontalAlignment covers all cases', () => {
|
|
|
522
522
|
t.setProperty('horizontalAlignment', 0);
|
|
523
523
|
expect(t.getHorizontalAlignment()).toBe('left');
|
|
524
524
|
t.setProperty('horizontalAlignment', 1);
|
|
525
|
-
expect(t.getHorizontalAlignment()).toBe('
|
|
525
|
+
expect(t.getHorizontalAlignment()).toBe('centre');
|
|
526
526
|
t.setProperty('horizontalAlignment', 2);
|
|
527
527
|
expect(t.getHorizontalAlignment()).toBe('right');
|
|
528
528
|
t.setProperty('horizontalAlignment', 3); t.setProperty('verticalAlignment', 0);
|
|
529
529
|
expect(t.getHorizontalAlignment()).toBe('aligned');
|
|
530
530
|
t.setProperty('horizontalAlignment', 4); t.setProperty('verticalAlignment', 0);
|
|
531
|
-
expect(t.getHorizontalAlignment()).toBe('
|
|
531
|
+
expect(t.getHorizontalAlignment()).toBe('centre');
|
|
532
532
|
t.setProperty('horizontalAlignment', 5); t.setProperty('verticalAlignment', 0);
|
|
533
533
|
expect(t.getHorizontalAlignment()).toBe('fit');
|
|
534
534
|
t.setProperty('horizontalAlignment', 99);
|