@design-core/core 0.0.1 → 0.0.3
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/.eslintrc.json +14 -7
- package/.github/workflows/DesignCoreQA.yml +3 -1
- package/README.md +11 -4
- package/TODO.md +19 -0
- package/core/core/core.js +49 -42
- package/core/designCore.js +61 -2
- package/core/dimensions/alignedDimension.js +142 -0
- package/core/dimensions/angularDimension.js +550 -0
- package/core/dimensions/baseCircularDimension.js +244 -0
- package/core/dimensions/baseDimension.js +558 -0
- package/core/dimensions/baseLinearDimension.js +371 -0
- package/core/dimensions/diametricDimension.js +82 -0
- package/core/dimensions/dimension.js +298 -0
- package/core/dimensions/linearDimension.js +29 -0
- package/core/dimensions/radialDimension.js +78 -0
- package/core/dimensions/rotatedDimension.js +167 -0
- package/core/entities/arc.js +314 -60
- package/core/entities/arctext.js +642 -0
- package/core/entities/basePolyline.js +553 -94
- package/core/entities/circle.js +181 -54
- package/core/entities/entity.js +154 -74
- package/core/entities/hatch.js +807 -0
- package/core/entities/insert.js +200 -39
- package/core/entities/line.js +196 -134
- package/core/entities/lwpolyline.js +21 -44
- package/core/entities/point.js +194 -29
- package/core/entities/polyline.js +54 -7
- package/core/entities/rectangle.js +43 -13
- package/core/entities/solid.js +43 -6
- package/core/entities/text.js +324 -181
- package/core/lib/boundingBox.js +73 -13
- package/core/lib/canvas.js +256 -65
- package/core/lib/clipboard.js +198 -0
- package/core/lib/colour.js +144 -0
- package/core/lib/colours.js +367 -301
- package/core/lib/commandLine.js +16 -28
- package/core/lib/commandManager.js +115 -58
- package/core/lib/constants.js +23 -0
- package/core/lib/dxf/dxf.js +249 -34
- package/core/lib/dxf/dxfFile.js +23 -38
- package/core/lib/dxf/dxfIterator.js +17 -5
- package/core/lib/dxf/dxfRead.js +23 -7
- package/core/lib/dxf/dxfWrite.js +39 -129
- package/core/lib/dxf/handleManager.js +97 -0
- package/core/lib/dxf/sections/blocks.js +16 -2
- package/core/lib/dxf/sections/entities.js +17 -3
- package/core/lib/dxf/sections/header.js +10 -1
- package/core/lib/dxf/sections/objects.js +36 -0
- package/core/lib/dxf/sections/section.js +43 -5
- package/core/lib/dxf/sections/tables.js +17 -3
- package/core/lib/entityManager.js +178 -0
- package/core/lib/fileio.js +14 -4
- package/core/lib/headers.js +229 -0
- package/core/lib/input.js +46 -0
- package/core/lib/inputManager.js +199 -194
- package/core/lib/intersect.js +341 -468
- package/core/lib/logging.js +25 -1
- package/core/lib/matrix.js +6 -8
- package/core/lib/mouse.js +24 -79
- package/core/lib/patterns.js +690 -0
- package/core/lib/promptOptions.js +133 -0
- package/core/lib/scene.js +71 -174
- package/core/lib/selectionManager.js +74 -48
- package/core/lib/selectionWindow.js +24 -10
- package/core/lib/settings.js +18 -11
- package/core/lib/snapping.js +129 -21
- package/core/lib/stateManager.js +288 -0
- package/core/lib/strings.js +57 -5
- package/core/lib/utils.js +95 -11
- package/core/objects/dictionary.js +43 -0
- package/core/objects/dictionaryManager.js +80 -0
- package/core/properties/dimType.js +117 -0
- package/core/properties/flags.js +66 -0
- package/core/properties/property.js +26 -0
- package/core/properties/propertyManager.js +65 -19
- package/core/tables/appId.js +31 -0
- package/core/tables/appIdManager.js +44 -0
- package/core/tables/block.js +323 -0
- package/core/tables/blockManager.js +48 -0
- package/core/tables/blockRecord.js +29 -0
- package/core/tables/blockRecordManager.js +37 -0
- package/core/tables/dimStyle.js +627 -0
- package/core/tables/dimStyleManager.js +187 -0
- package/core/tables/endblk.js +28 -0
- package/core/tables/layer.js +219 -0
- package/core/tables/layerManager.js +47 -0
- package/core/tables/ltype.js +85 -0
- package/core/tables/ltypeManager.js +65 -0
- package/core/tables/style.js +145 -0
- package/core/tables/styleManager.js +55 -0
- package/core/tables/styleManagerBase.js +110 -0
- package/core/tables/tableManagerBase.js +354 -0
- package/core/tables/ucs.js +28 -0
- package/core/tables/ucsManager.js +44 -0
- package/core/tables/view.js +28 -0
- package/core/tables/viewManager.js +44 -0
- package/core/tables/vport.js +70 -0
- package/core/tables/vportManager.js +65 -0
- package/core/tools/chamfer.js +343 -0
- package/core/tools/chamferFilletBase.js +162 -0
- package/core/tools/copy.js +68 -40
- package/core/tools/copybase.js +65 -0
- package/core/tools/copyclip.js +59 -0
- package/core/tools/cornerEntity.js +138 -0
- package/core/tools/cutclip.js +72 -0
- package/core/tools/distance.js +37 -9
- package/core/tools/erase.js +43 -13
- package/core/tools/explode.js +117 -0
- package/core/tools/extend.js +71 -32
- package/core/tools/fillet.js +336 -0
- package/core/tools/identify.js +33 -6
- package/core/tools/matchProp.js +106 -0
- package/core/tools/mirror.js +141 -0
- package/core/tools/move.js +65 -32
- package/core/tools/offset.js +321 -0
- package/core/tools/pan.js +54 -0
- package/core/tools/pasteclip.js +93 -0
- package/core/tools/purge.js +90 -0
- package/core/tools/rotate.js +105 -70
- package/core/tools/scale.js +166 -0
- package/core/tools/tool.js +14 -4
- package/core/tools/trim.js +71 -32
- package/core/tools/zoom.js +152 -0
- package/package.json +3 -305
- package/test/dimensions/alignedDimension.test.js +211 -0
- package/test/dimensions/angularDimension.test.js +243 -0
- package/test/dimensions/baseDimension.test.js +239 -0
- package/test/dimensions/diametricDimension.test.js +203 -0
- package/test/dimensions/dimension.test.js +102 -0
- package/test/dimensions/radialDimension.test.js +203 -0
- package/test/dimensions/rotatedDimension.test.js +224 -0
- package/test/entities/arc.test.js +463 -41
- package/test/entities/arctext.test.js +329 -0
- package/test/entities/basePolyline.test.js +459 -10
- package/test/entities/circle.test.js +312 -7
- package/test/entities/entity.test.js +28 -9
- package/test/entities/hatch.test.js +606 -0
- package/test/entities/insert.test.js +90 -0
- package/test/entities/line.test.js +182 -6
- package/test/entities/point.test.js +375 -37
- package/test/entities/solid.test.js +156 -0
- package/test/entities/text.test.js +533 -7
- package/test/integration/exportIntegration.reference.dxf +1706 -0
- package/test/integration/exportIntegration.test.js +186 -0
- package/test/integration/importExportIntegration.test.js +126 -0
- package/test/integration/intersectionIntegration.test.js +880 -0
- package/test/integration/userInputIntegration.reference.dxf +1410 -0
- package/test/integration/userInputIntegration.test.js +269 -0
- package/test/lib/boundingBox.test.js +26 -2
- package/test/lib/canvas.test.js +613 -5
- package/test/lib/clipboard.test.js +70 -0
- package/test/lib/colour.test.js +114 -0
- package/test/lib/colours.test.js +63 -18
- package/test/lib/commandLine.test.js +159 -22
- package/test/lib/commandManager.test.js +4 -4
- package/test/lib/constants.test.js +9 -0
- package/test/lib/dxf/dxfFile.test.js +6 -2
- package/test/lib/dxf/dxfIterator.test.js +1 -1
- package/test/lib/dxf/dxfWrite.test.js +173 -0
- package/test/lib/dxf/handleManager.test.js +137 -0
- package/test/lib/dxf/sections/blocks.test.js +5 -5
- package/test/lib/dxf/sections/entities.test.js +4 -4
- package/test/lib/dxf/sections/header.test.js +18 -4
- package/test/lib/dxf/sections/objects.test.js +132 -0
- package/test/lib/dxf/sections/section.test.js +29 -29
- package/test/lib/dxf/sections/tables.test.js +3 -3
- package/test/lib/entityManager.test.js +163 -0
- package/test/lib/headers.test.js +233 -0
- package/test/lib/inputManager.test.js +1144 -5
- package/test/lib/intersect.test.js +454 -331
- package/test/lib/logging.test.js +1 -1
- package/test/lib/matrix.test.js +1 -1
- package/test/lib/mouse.test.js +327 -4
- package/test/lib/patterns.test.js +105 -0
- package/test/lib/promptOptions.test.js +179 -0
- package/test/lib/scene.test.js +16 -52
- package/test/lib/selectionManager.test.js +17 -5
- package/test/lib/settings.test.js +111 -5
- package/test/lib/snapping.test.js +142 -4
- package/test/lib/stateManager.test.js +155 -0
- package/test/lib/utils.test.js +81 -1
- package/test/objects/dictionary.test.js +81 -0
- package/test/objects/dictionaryManager.test.js +34 -0
- package/test/properties/dimType.test.js +62 -0
- package/test/properties/flags.test.js +164 -0
- package/test/properties/property.test.js +13 -0
- package/test/properties/propertyManager.test.js +10 -11
- package/test/tables/appId.test.js +46 -0
- package/test/tables/appIdManager.test.js +72 -0
- package/test/tables/block.test.js +157 -0
- package/test/tables/blockManager.test.js +52 -0
- package/test/tables/blockRecord.test.js +39 -0
- package/test/tables/blockRecordManager.test.js +60 -0
- package/test/tables/dimstyle.test.js +72 -0
- package/test/tables/endblk.test.js +30 -0
- package/test/tables/layer.test.js +95 -0
- package/test/tables/layerManager.test.js +172 -0
- package/test/{styles → tables}/ltype.test.js +7 -7
- package/test/{styles → tables}/ltypeManager.test.js +2 -2
- package/test/tables/style.test.js +44 -0
- package/test/tables/stylemanagerbase.test.js +220 -0
- package/test/tables/tableManagerBase.test.js +194 -0
- package/test/tables/ucs.test.js +37 -0
- package/test/tables/ucsManager.test.js +48 -0
- package/test/tables/view.test.js +37 -0
- package/test/tables/viewManager.test.js +48 -0
- package/test/tables/vport.test.js +117 -0
- package/test/tables/vportManager.test.js +54 -0
- package/test/test-helpers/test-helpers.js +66 -0
- package/test/tools/chamfer.test.js +970 -0
- package/test/tools/chamferFilletBase.test.js +446 -0
- package/test/tools/copy.test.js +22 -14
- package/test/tools/copybase.test.js +93 -0
- package/test/tools/copyclip.test.js +92 -0
- package/test/tools/cornerEntity.test.js +201 -0
- package/test/tools/cutclip.test.js +94 -0
- package/test/tools/distance.test.js +140 -18
- package/test/tools/erase.test.js +12 -12
- package/test/tools/explode.test.js +45 -0
- package/test/tools/extend.test.js +326 -44
- package/test/tools/fillet.test.js +831 -0
- package/test/tools/identify.test.js +115 -16
- package/test/tools/matchProp.test.js +84 -0
- package/test/tools/mirror.test.js +475 -0
- package/test/tools/move.test.js +75 -19
- package/test/tools/offset.test.js +748 -0
- package/test/tools/pan.test.js +72 -0
- package/test/tools/pasteclip.test.js +100 -0
- package/test/tools/purge.test.js +89 -0
- package/test/tools/rotate.test.js +89 -23
- package/test/tools/scale.test.js +529 -0
- package/test/tools/trim.test.js +419 -84
- package/test/tools/zoom.test.js +504 -0
- package/core/entities/alignedDimension.js +0 -279
- package/core/entities/angularDimension.js +0 -194
- package/core/entities/baseDimension.js +0 -227
- package/core/entities/block.js +0 -247
- package/core/entities/diametricDimension.js +0 -133
- package/core/entities/dimension.js +0 -202
- package/core/entities/radialDimension.js +0 -126
- package/core/styles/dimStyle.js +0 -719
- package/core/styles/dimStyleManager.js +0 -47
- package/core/styles/layer.js +0 -133
- package/core/styles/layerManager.js +0 -40
- package/core/styles/ltype.js +0 -86
- package/core/styles/ltypeManager.js +0 -50
- package/core/styles/style.js +0 -158
- package/core/styles/styleManager.js +0 -43
- package/core/styles/styleManagerBase.js +0 -299
- package/test/entities/block.test.js +0 -22
- package/test/styles/dimstyle.test.js +0 -19
- package/test/styles/layerManager.test.js +0 -150
- package/test/styles/style.test.js +0 -33
- package/test/styles/stylemanagerbase.test.js +0 -219
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
import { Colour, EntityColour } from '../../core/lib/colour.js';
|
|
3
|
+
|
|
4
|
+
test('Test Colour', () => {
|
|
5
|
+
const colour = new Colour();
|
|
6
|
+
expect(colour.aci).toEqual(7);
|
|
7
|
+
expect(colour.rgb).toEqual({ 'b': 254, 'g': 254, 'r': 254 });
|
|
8
|
+
|
|
9
|
+
const colour4 = new Colour(4);
|
|
10
|
+
expect(colour4.aci).toEqual(4);
|
|
11
|
+
expect(colour4.rgb).toEqual({ 'b': 255, 'g': 255, 'r': 0 });
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('Test Colour.isTrueColour', () => {
|
|
15
|
+
const colour = new Colour();
|
|
16
|
+
expect(colour.isTrueColour).toEqual(false);
|
|
17
|
+
|
|
18
|
+
const trueColour = new Colour();
|
|
19
|
+
trueColour.setColour({ r: 200, g: 100, b: 50 });
|
|
20
|
+
expect(trueColour.isTrueColour).toEqual(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('Test Colour.getColour', () => {
|
|
24
|
+
const colour = new Colour();
|
|
25
|
+
expect(colour.getColour()).toEqual({ 'b': 254, 'g': 254, 'r': 254 });
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
test('Test Colour.setColour', () => {
|
|
30
|
+
const colour = new Colour();
|
|
31
|
+
colour.setColour({ r: 200, g: 100, b: 50 });
|
|
32
|
+
expect(colour.rgb).toEqual({ 'r': 200, 'g': 100, 'b': 50 });
|
|
33
|
+
expect(colour.aci).toEqual(7);
|
|
34
|
+
|
|
35
|
+
colour.setColour({ r: 0, g: 255, b: 255 });
|
|
36
|
+
expect(colour.rgb).toEqual({ 'r': 0, 'g': 255, 'b': 255 });
|
|
37
|
+
expect(colour.aci).toEqual(4);
|
|
38
|
+
|
|
39
|
+
colour.setColour({ r: 1, g: 2, b: 3 });
|
|
40
|
+
expect(colour.rgb).toEqual({ 'r': 1, 'g': 2, 'b': 3 });
|
|
41
|
+
expect(colour.aci).toEqual(7);
|
|
42
|
+
|
|
43
|
+
colour.setColour({ r: 1000, g: 2000, b: 3000 });
|
|
44
|
+
expect(colour.rgb).toEqual({ 'r': 1, 'g': 2, 'b': 3 });
|
|
45
|
+
expect(colour.aci).toEqual(7);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('Test Colour.setColourFromACI', () => {
|
|
49
|
+
const colour = new Colour();
|
|
50
|
+
colour.setColourFromACI(7);
|
|
51
|
+
expect(colour.rgb).toEqual({ 'r': 254, 'g': 254, 'b': 254 });
|
|
52
|
+
expect(colour.aci).toEqual(7);
|
|
53
|
+
|
|
54
|
+
colour.setColourFromACI(50);
|
|
55
|
+
expect(colour.rgb).toEqual({ 'r': 254, 'g': 254, 'b': 0 });
|
|
56
|
+
expect(colour.aci).toEqual(50);
|
|
57
|
+
|
|
58
|
+
colour.setColourFromACI(-1);
|
|
59
|
+
expect(colour.rgb).toEqual({ 'r': 254, 'g': 254, 'b': 0 });
|
|
60
|
+
expect(colour.aci).toEqual(50);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/*
|
|
64
|
+
Entity Colour - Included byblock and bylayer
|
|
65
|
+
*/
|
|
66
|
+
test('Test EntityColour.setColour', () => {
|
|
67
|
+
const colour = new EntityColour();
|
|
68
|
+
|
|
69
|
+
expect(colour.byLayer).toEqual(true);
|
|
70
|
+
expect(colour.byBlock).toEqual(false);
|
|
71
|
+
|
|
72
|
+
colour.setColour({ r: 200, g: 100, b: 50 });
|
|
73
|
+
expect(colour.rgb).toEqual({ 'r': 200, 'g': 100, 'b': 50 });
|
|
74
|
+
expect(colour.aci).toEqual(7);
|
|
75
|
+
expect(colour.byLayer).toEqual(false);
|
|
76
|
+
expect(colour.byBlock).toEqual(false);
|
|
77
|
+
|
|
78
|
+
colour.setColour({ r: 0, g: 0, b: 0 });
|
|
79
|
+
expect(colour.rgb).toEqual({ 'r': 0, 'g': 0, 'b': 0 });
|
|
80
|
+
expect(colour.aci).toEqual(0);
|
|
81
|
+
expect(colour.byLayer).toEqual(false);
|
|
82
|
+
expect(colour.byBlock).toEqual(true);
|
|
83
|
+
|
|
84
|
+
colour.setColour('BYLAYER');
|
|
85
|
+
expect(colour.aci).toEqual(256);
|
|
86
|
+
expect(colour.byLayer).toEqual(true);
|
|
87
|
+
expect(colour.byBlock).toEqual(false);
|
|
88
|
+
|
|
89
|
+
colour.setColour('BYBLOCK');
|
|
90
|
+
expect(colour.aci).toEqual(0);
|
|
91
|
+
expect(colour.byLayer).toEqual(false);
|
|
92
|
+
expect(colour.byBlock).toEqual(true);
|
|
93
|
+
|
|
94
|
+
colour.setColour('bylayer');
|
|
95
|
+
expect(colour.aci).toEqual(256);
|
|
96
|
+
expect(colour.byLayer).toEqual(true);
|
|
97
|
+
expect(colour.byBlock).toEqual(false);
|
|
98
|
+
|
|
99
|
+
colour.setColour('byblock');
|
|
100
|
+
expect(colour.aci).toEqual(0);
|
|
101
|
+
expect(colour.byLayer).toEqual(false);
|
|
102
|
+
expect(colour.byBlock).toEqual(true);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
test('Colour Conversion Test', () => {
|
|
107
|
+
const colour = new EntityColour();
|
|
108
|
+
|
|
109
|
+
// Check the returned ACI is the same as the set ACI
|
|
110
|
+
for (let i = 0; i < 255; i++) {
|
|
111
|
+
colour.setColourFromACI(i);
|
|
112
|
+
expect(colour.aci).toEqual(i);
|
|
113
|
+
}
|
|
114
|
+
});
|
package/test/lib/colours.test.js
CHANGED
|
@@ -1,29 +1,74 @@
|
|
|
1
1
|
|
|
2
|
-
import {Colours} from '../../core/lib/colours.js';
|
|
2
|
+
import { Colours } from '../../core/lib/colours.js';
|
|
3
3
|
|
|
4
|
-
test('Test Colours.
|
|
5
|
-
expect(Colours.
|
|
6
|
-
expect(Colours.
|
|
4
|
+
test('Test Colours.isRGB', () => {
|
|
5
|
+
expect(Colours.isRGB({ r: 255, g: 255, b: 255 })).toEqual(true);
|
|
6
|
+
expect(Colours.isRGB({ r: 255, b: 255 })).toEqual(false);
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
test('Test Colours.
|
|
10
|
-
expect(Colours.
|
|
11
|
-
expect(Colours.
|
|
9
|
+
test('Test Colours.aciToRGB', () => {
|
|
10
|
+
expect(Colours.aciToRGB(0)).toEqual({ r: 0, g: 0, b: 0 });
|
|
11
|
+
expect(Colours.aciToRGB(255)).toEqual({ r: 255, g: 255, b: 255 });
|
|
12
|
+
|
|
13
|
+
// aci 7 should change colour depending on the background colour
|
|
14
|
+
expect(Colours.aciToRGB(255)).toEqual({ r: 255, g: 255, b: 255 });
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('Test Colours.rgbToACI', () => {
|
|
18
|
+
expect(Colours.rgbToACI({ r: 0, g: 0, b: 0 })).toEqual(0);
|
|
19
|
+
expect(Colours.rgbToACI({ r: 254, g: 254, b: 254 })).toEqual(7);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('Test Colours.rgbToString', () => {
|
|
23
|
+
expect(Colours.rgbToString({ r: 0, g: 0, b: 0 })).toEqual('rgb(0, 0, 0)');
|
|
24
|
+
expect(Colours.rgbToString({ r: 255, g: 255, b: 255 })).toEqual('rgb(255, 255, 255)');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('Test Colours.rgbToScaledRGB', () => {
|
|
28
|
+
expect(Colours.rgbToScaledRGB({ r: 255, g: 255, b: 255 })).toEqual({ r: 1, g: 1, b: 1 });
|
|
29
|
+
expect(Colours.rgbToScaledRGB({ r: 100, g: 100, b: 100 })).toEqual({ r: 100 / 255, g: 100 / 255, b: 100 / 255 });
|
|
30
|
+
expect(Colours.rgbToScaledRGB({ r: 1, g: 1 })).toBeUndefined();
|
|
31
|
+
expect(Colours.rgbToScaledRGB({})).toBeUndefined();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('Test Colours.trueColourToRGB', () => {
|
|
35
|
+
// rgb(200, 100,50)
|
|
36
|
+
// hex 0x00C86432
|
|
37
|
+
// int 13132850
|
|
38
|
+
const rgb = Colours.trueColourToRGB(13132850);
|
|
39
|
+
expect(rgb.r).toBe(200);
|
|
40
|
+
expect(rgb.g).toBe(100);
|
|
41
|
+
expect(rgb.b).toBe(50);
|
|
42
|
+
|
|
43
|
+
expect(Colours.trueColourToRGB()).toBeUndefined();
|
|
12
44
|
});
|
|
13
45
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
46
|
+
|
|
47
|
+
test('Test Colours.rgbToTrueColour', () => {
|
|
48
|
+
// rgb(200, 100,50)
|
|
49
|
+
// hex 0x00C86432
|
|
50
|
+
// int 13132850
|
|
51
|
+
expect(Colours.rgbToTrueColour({ r: 200, g: 100, b: 50 })).toBe(13132850);
|
|
52
|
+
expect(Colours.rgbToTrueColour()).toBeUndefined();
|
|
17
53
|
});
|
|
18
54
|
|
|
19
|
-
test('Test
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
55
|
+
test('Test Colour Sequence', () => {
|
|
56
|
+
// loop through all colour values and check the ACI numbers
|
|
57
|
+
// ensure the numbers are sequential
|
|
58
|
+
let index = 0;
|
|
59
|
+
|
|
60
|
+
for (const key in Colours.rgb_conversion_table) {
|
|
61
|
+
if (!isNaN(key)) {
|
|
62
|
+
expect(parseInt(key)).toBe(index);
|
|
63
|
+
index++;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
23
66
|
});
|
|
24
67
|
|
|
25
|
-
test('Test
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
68
|
+
test('Colours Conversion Test', () => {
|
|
69
|
+
// Check the returned ACI is the same as the set ACI
|
|
70
|
+
for (let i = 0; i < 255; i++) {
|
|
71
|
+
const rgb = Colours.aciToRGB(i);
|
|
72
|
+
expect(Colours.rgbToACI(rgb)).toEqual(i);
|
|
73
|
+
}
|
|
29
74
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {Core} from '../../core/core/core.js';
|
|
2
|
-
import {Input, PromptOptions} from '../../core/lib/inputManager.js';
|
|
3
|
-
import {Strings} from '../../core/lib/strings.js';
|
|
1
|
+
import { Core } from '../../core/core/core.js';
|
|
2
|
+
import { Input, PromptOptions } from '../../core/lib/inputManager.js';
|
|
3
|
+
import { Strings } from '../../core/lib/strings.js';
|
|
4
|
+
import { expect, jest } from '@jest/globals';
|
|
4
5
|
|
|
5
6
|
const core = new Core();
|
|
6
7
|
const commandline = core.commandLine; // new CommandLine();
|
|
@@ -16,24 +17,7 @@ test('Test Commandline.setPrompt', () => {
|
|
|
16
17
|
const testText = 'TestTest';
|
|
17
18
|
commandline.setPrompt(testText);
|
|
18
19
|
expect(commandline.prompt).toBe(`${testText}:`);
|
|
19
|
-
|
|
20
|
-
// test setPrompt with default - command should be set to default value
|
|
21
|
-
const testTextWithDefault = 'TestTest <default>';
|
|
22
|
-
commandline.setPrompt(testTextWithDefault);
|
|
23
|
-
expect(commandline.prompt).toBe(`${testTextWithDefault}:`);
|
|
24
|
-
expect(commandline.command).toBe('default');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('Test Commandline.parseCommandDefault', () => {
|
|
28
|
-
const commandDefault = ['<default>'];
|
|
29
|
-
const defaultValue = commandline.parseCommandDefault(commandDefault);
|
|
30
|
-
expect(defaultValue).toBe(`default`);
|
|
31
|
-
|
|
32
|
-
// only a single default is valid
|
|
33
|
-
commandDefault.push('<second value>');
|
|
34
|
-
expect(() => {
|
|
35
|
-
commandline.parseCommandDefault(commandDefault);
|
|
36
|
-
}).toThrow();
|
|
20
|
+
expect(commandline.command).toBe('');
|
|
37
21
|
});
|
|
38
22
|
|
|
39
23
|
test('Test Commandline.update', () => {
|
|
@@ -139,7 +123,7 @@ test('Test CommandLine.parseInput', () => {
|
|
|
139
123
|
expect(relPoint1.x).toBe(101);
|
|
140
124
|
expect(relPoint1.y).toBe(102);
|
|
141
125
|
|
|
142
|
-
core.scene.inputManager.
|
|
126
|
+
core.scene.inputManager.startCommand('Line');
|
|
143
127
|
core.scene.inputManager.activeCommand.points.push(relPoint1);
|
|
144
128
|
const relPoint2 = commandline.parseInput('@101,102');
|
|
145
129
|
expect(relPoint2.constructor.name).toBe('Point');
|
|
@@ -215,6 +199,159 @@ test('Test CommandLine.addToCommandHistory', () => {
|
|
|
215
199
|
commandline.lastCommand = [];
|
|
216
200
|
});
|
|
217
201
|
|
|
202
|
+
test('Test CommandLine.setUpdateFunction registers callback and triggers it', () => {
|
|
203
|
+
const callback = jest.fn();
|
|
204
|
+
commandline.setUpdateFunction(callback);
|
|
205
|
+
expect(callback).toHaveBeenCalled();
|
|
206
|
+
commandline.setUpdateFunction(undefined);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
test('Test CommandLine.escapePressed delegates to inputManager.onEscapePressed', () => {
|
|
210
|
+
const inputManager = core.scene.inputManager;
|
|
211
|
+
const spy = jest.spyOn(inputManager, 'onEscapePressed').mockImplementation(() => {});
|
|
212
|
+
commandline.escapePressed();
|
|
213
|
+
expect(spy).toHaveBeenCalled();
|
|
214
|
+
spy.mockRestore();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test('Test CommandLine.deletePressed delegates to inputManager.onCommand with Erase', () => {
|
|
218
|
+
const inputManager = core.scene.inputManager;
|
|
219
|
+
const spy = jest.spyOn(inputManager, 'onCommand').mockImplementation(() => {});
|
|
220
|
+
commandline.deletePressed();
|
|
221
|
+
expect(spy).toHaveBeenCalledWith('Erase');
|
|
222
|
+
spy.mockRestore();
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test('Test CommandLine.enterPressed with empty command calls onEnterPressed', () => {
|
|
226
|
+
const inputManager = core.scene.inputManager;
|
|
227
|
+
commandline.resetPrompt();
|
|
228
|
+
const spy = jest.spyOn(inputManager, 'onEnterPressed').mockImplementation(() => {});
|
|
229
|
+
commandline.enterPressed();
|
|
230
|
+
expect(spy).toHaveBeenCalled();
|
|
231
|
+
spy.mockRestore();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
test('Test CommandLine.enterPressed with command calls onCommand with parsed value', () => {
|
|
235
|
+
const inputManager = core.scene.inputManager;
|
|
236
|
+
commandline.resetPrompt();
|
|
237
|
+
commandline.handleKeys('42');
|
|
238
|
+
const spy = jest.spyOn(inputManager, 'onCommand').mockImplementation(() => {});
|
|
239
|
+
commandline.enterPressed();
|
|
240
|
+
expect(spy).toHaveBeenCalledWith(42);
|
|
241
|
+
spy.mockRestore();
|
|
242
|
+
commandline.resetPrompt();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('Test CommandLine.handleKeys routes Backspace to backPressed', () => {
|
|
246
|
+
commandline.handleKeys('123');
|
|
247
|
+
commandline.handleKeys('Backspace');
|
|
248
|
+
expect(commandline.command).toBe('12');
|
|
249
|
+
commandline.resetPrompt();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
test('Test CommandLine.handleKeys routes Enter to enterPressed', () => {
|
|
253
|
+
const spy = jest.spyOn(commandline, 'enterPressed').mockImplementation(() => {});
|
|
254
|
+
commandline.handleKeys('Enter');
|
|
255
|
+
expect(spy).toHaveBeenCalled();
|
|
256
|
+
spy.mockRestore();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
test('Test CommandLine.handleKeys routes Escape to escapePressed', () => {
|
|
260
|
+
const spy = jest.spyOn(commandline, 'escapePressed').mockImplementation(() => {});
|
|
261
|
+
commandline.handleKeys('Escape');
|
|
262
|
+
expect(spy).toHaveBeenCalled();
|
|
263
|
+
spy.mockRestore();
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
test('Test CommandLine.handleKeys routes Space to spacePressed', () => {
|
|
267
|
+
const spy = jest.spyOn(commandline, 'spacePressed').mockImplementation(() => {});
|
|
268
|
+
commandline.handleKeys('Space');
|
|
269
|
+
expect(spy).toHaveBeenCalled();
|
|
270
|
+
spy.mockRestore();
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
test('Test CommandLine.handleKeys routes Delete to deletePressed', () => {
|
|
274
|
+
const spy = jest.spyOn(commandline, 'deletePressed').mockImplementation(() => {});
|
|
275
|
+
commandline.handleKeys('Delete');
|
|
276
|
+
expect(spy).toHaveBeenCalled();
|
|
277
|
+
spy.mockRestore();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test('Test CommandLine.handleKeys routes Up-Arrow to previousCommand up', () => {
|
|
281
|
+
const spy = jest.spyOn(commandline, 'previousCommand').mockImplementation(() => {});
|
|
282
|
+
commandline.handleKeys('Up-Arrow');
|
|
283
|
+
expect(spy).toHaveBeenCalledWith('up');
|
|
284
|
+
spy.mockRestore();
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test('Test CommandLine.handleKeys routes Down-Arrow to previousCommand down', () => {
|
|
288
|
+
const spy = jest.spyOn(commandline, 'previousCommand').mockImplementation(() => {});
|
|
289
|
+
commandline.handleKeys('Down-Arrow');
|
|
290
|
+
expect(spy).toHaveBeenCalledWith('down');
|
|
291
|
+
spy.mockRestore();
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('Test CommandLine.handleKeys with undefined key does not change command', () => {
|
|
295
|
+
commandline.resetPrompt();
|
|
296
|
+
commandline.handleKeys(undefined);
|
|
297
|
+
expect(commandline.command).toBe('');
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('Test CommandLine.previousCommand cycles up through history', () => {
|
|
301
|
+
commandline.lastCommand = ['Circle', 'Line', 'Rect'];
|
|
302
|
+
commandline.lastCommandPosition = -1;
|
|
303
|
+
|
|
304
|
+
commandline.previousCommand('up');
|
|
305
|
+
expect(commandline.command).toBe('Circle');
|
|
306
|
+
expect(commandline.lastCommandPosition).toBe(0);
|
|
307
|
+
|
|
308
|
+
commandline.previousCommand('up');
|
|
309
|
+
expect(commandline.command).toBe('Line');
|
|
310
|
+
expect(commandline.lastCommandPosition).toBe(1);
|
|
311
|
+
|
|
312
|
+
commandline.previousCommand('up');
|
|
313
|
+
expect(commandline.command).toBe('Rect');
|
|
314
|
+
expect(commandline.lastCommandPosition).toBe(2);
|
|
315
|
+
|
|
316
|
+
// At end of history - stays at last entry
|
|
317
|
+
commandline.previousCommand('up');
|
|
318
|
+
expect(commandline.command).toBe('Rect');
|
|
319
|
+
expect(commandline.lastCommandPosition).toBe(2);
|
|
320
|
+
|
|
321
|
+
commandline.lastCommand = [];
|
|
322
|
+
commandline.resetPrompt();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
test('Test CommandLine.previousCommand cycles down through history', () => {
|
|
326
|
+
commandline.lastCommand = ['Circle', 'Line', 'Rect'];
|
|
327
|
+
commandline.lastCommandPosition = 2;
|
|
328
|
+
commandline.command = 'Rect';
|
|
329
|
+
|
|
330
|
+
commandline.previousCommand('down');
|
|
331
|
+
expect(commandline.command).toBe('Line');
|
|
332
|
+
expect(commandline.lastCommandPosition).toBe(1);
|
|
333
|
+
|
|
334
|
+
commandline.previousCommand('down');
|
|
335
|
+
expect(commandline.command).toBe('Circle');
|
|
336
|
+
expect(commandline.lastCommandPosition).toBe(0);
|
|
337
|
+
|
|
338
|
+
// At position 0 going down resets the prompt
|
|
339
|
+
commandline.previousCommand('down');
|
|
340
|
+
expect(commandline.command).toBe('');
|
|
341
|
+
expect(commandline.lastCommandPosition).toBe(-1);
|
|
342
|
+
|
|
343
|
+
commandline.lastCommand = [];
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
test('Test CommandLine.previousCommand up with empty history is a no-op', () => {
|
|
347
|
+
commandline.lastCommand = [];
|
|
348
|
+
commandline.lastCommandPosition = -1;
|
|
349
|
+
commandline.command = '';
|
|
350
|
+
commandline.previousCommand('up');
|
|
351
|
+
expect(commandline.command).toBe('');
|
|
352
|
+
expect(commandline.lastCommandPosition).toBe(-1);
|
|
353
|
+
});
|
|
354
|
+
|
|
218
355
|
test('Test CommandLine.addToCommandHistory', () => {
|
|
219
356
|
commandline.addToCommandHistory('3');
|
|
220
357
|
commandline.addToCommandHistory('2');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
import {Core} from '../../core/core/core.js';
|
|
3
|
-
import {Point} from '../../core/entities/point.js';
|
|
2
|
+
import { Core } from '../../core/core/core.js';
|
|
3
|
+
import { Point } from '../../core/entities/point.js';
|
|
4
4
|
|
|
5
5
|
const core = new Core();
|
|
6
6
|
const commandManager = core.commandManager;
|
|
@@ -10,10 +10,10 @@ test('Test CommandManager.createNew', () => {
|
|
|
10
10
|
const endPoint = new Point(10, 10);
|
|
11
11
|
const points = [startPoint, endPoint];
|
|
12
12
|
|
|
13
|
-
const line = commandManager.createNew('Line', {points: points});
|
|
13
|
+
const line = commandManager.createNew('Line', { points: points });
|
|
14
14
|
expect(typeof line).toBe('object');
|
|
15
15
|
|
|
16
|
-
const test = commandManager.createNew('test', {points: points});
|
|
16
|
+
const test = commandManager.createNew('test', { points: points });
|
|
17
17
|
expect(typeof test).toBe('undefined');
|
|
18
18
|
});
|
|
19
19
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Constants } from '../../core/lib/constants.js';
|
|
2
|
+
|
|
3
|
+
test('Constants.Tolerance.EPSILON is 1e-10', () => {
|
|
4
|
+
expect(Constants.Tolerance.EPSILON).toBe(1e-10);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test('Constants.Precision.DECIMALPLACES is 5', () => {
|
|
8
|
+
expect(Constants.Precision.DECIMALPLACES).toBe(5);
|
|
9
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DXFFile} from '../../../core/lib/dxf/dxfFile.js';
|
|
1
|
+
import { DXFFile } from '../../../core/lib/dxf/dxfFile.js';
|
|
2
2
|
|
|
3
3
|
const file = new DXFFile();
|
|
4
4
|
|
|
@@ -15,8 +15,12 @@ test('Test DXFFile.writeGroupCode', () => {
|
|
|
15
15
|
file.writeGroupCode('groupCode', 'groupValue');
|
|
16
16
|
|
|
17
17
|
const output = 'groupCode\ngroupValue\n';
|
|
18
|
-
|
|
19
18
|
expect(file.contents).toEqual(output);
|
|
19
|
+
|
|
20
|
+
// throw on undefined values
|
|
21
|
+
expect(() => {
|
|
22
|
+
file.writeGroupCode('groupCode', undefined);
|
|
23
|
+
}).toThrow();
|
|
20
24
|
});
|
|
21
25
|
|
|
22
26
|
test('Test DXFFile.clearFile', () => {
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { DXFWriter } from '../../../core/lib/dxf/dxfWrite.js';
|
|
2
|
+
import { DXFFile } from '../../../core/lib/dxf/dxfFile.js';
|
|
3
|
+
import { DesignCore } from '../../../core/designCore.js';
|
|
4
|
+
import { jest } from '@jest/globals';
|
|
5
|
+
|
|
6
|
+
const createManager = (styleName = 'default') => ({
|
|
7
|
+
items: [],
|
|
8
|
+
getCstyle: jest.fn(() => styleName),
|
|
9
|
+
dxf: jest.fn(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const createCoreMock = (options = {}) => {
|
|
13
|
+
const blocks = options.blocks || [];
|
|
14
|
+
const entities = options.entities || [];
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
dxfVersion: options.dxfVersion || 'R2018',
|
|
18
|
+
handleManager: { next() {
|
|
19
|
+
return '1';
|
|
20
|
+
}, get handseed() {
|
|
21
|
+
return '1';
|
|
22
|
+
} },
|
|
23
|
+
layerManager: options.layerManager || createManager('Layer0'),
|
|
24
|
+
ltypeManager: options.ltypeManager || createManager('Continuous'),
|
|
25
|
+
styleManager: options.styleManager || createManager('Standard'),
|
|
26
|
+
dimStyleManager: options.dimStyleManager || createManager('ISO-25'),
|
|
27
|
+
viewManager: options.viewManager || { dxf: jest.fn() },
|
|
28
|
+
vportManager: options.vportManager || { dxf: jest.fn() },
|
|
29
|
+
ucsManager: options.ucsManager || { dxf: jest.fn() },
|
|
30
|
+
appIdManager: options.appIdManager || { dxf: jest.fn() },
|
|
31
|
+
blockRecordManager: options.blockRecordManager || { dxf: jest.fn() },
|
|
32
|
+
dictionaryManager: options.dictionaryManager || { dxf: jest.fn() },
|
|
33
|
+
scene: {
|
|
34
|
+
dxf: jest.fn(),
|
|
35
|
+
headers: { dxf: jest.fn(), dxfVersion: options.dxfVersion || 'R2018' },
|
|
36
|
+
entities: {
|
|
37
|
+
count: jest.fn(() => entities.length),
|
|
38
|
+
get: jest.fn((index) => entities[index]),
|
|
39
|
+
},
|
|
40
|
+
blockManager: {
|
|
41
|
+
items: blocks,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
describe('DXFWriter', () => {
|
|
48
|
+
let originalCore;
|
|
49
|
+
|
|
50
|
+
beforeAll(() => {
|
|
51
|
+
originalCore = DesignCore._core;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
afterAll(() => {
|
|
55
|
+
DesignCore.Core = originalCore;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('Test DXFWriter.writeHeaders', () => {
|
|
59
|
+
const core = createCoreMock({
|
|
60
|
+
entities: [{}, {}],
|
|
61
|
+
blocks: [{ name: 'BlockA' }, { name: 'BlockB' }],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
core.layerManager.items = [{}, {}, {}];
|
|
65
|
+
core.ltypeManager.items = [{}, {}, {}, {}];
|
|
66
|
+
core.styleManager.items = [{}, {}, {}, {}, {}];
|
|
67
|
+
core.dimStyleManager.items = [{}, {}, {}, {}, {}, {}];
|
|
68
|
+
|
|
69
|
+
DesignCore.Core = core;
|
|
70
|
+
|
|
71
|
+
const writer = new DXFWriter();
|
|
72
|
+
const file = new DXFFile('R2018');
|
|
73
|
+
writer.writeHeaders(file);
|
|
74
|
+
|
|
75
|
+
expect(file.contents).toContain('0\nSECTION\n2\nHEADER\n');
|
|
76
|
+
expect(core.scene.headers.dxf).toHaveBeenCalledWith(file);
|
|
77
|
+
expect(file.contents).toContain('0\nENDSEC\n');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('Test DXFWriter.writeTables', () => {
|
|
81
|
+
const core = createCoreMock({
|
|
82
|
+
blocks: [{ name: 'BlockOne' }, { name: 'BlockTwo' }],
|
|
83
|
+
});
|
|
84
|
+
DesignCore.Core = core;
|
|
85
|
+
|
|
86
|
+
const writer = new DXFWriter();
|
|
87
|
+
const file = new DXFFile('R2018');
|
|
88
|
+
writer.writeTables(file);
|
|
89
|
+
|
|
90
|
+
expect(core.ltypeManager.dxf).toHaveBeenCalledWith(file);
|
|
91
|
+
expect(core.layerManager.dxf).toHaveBeenCalledWith(file);
|
|
92
|
+
expect(core.styleManager.dxf).toHaveBeenCalledWith(file);
|
|
93
|
+
expect(core.dimStyleManager.dxf).toHaveBeenCalledWith(file);
|
|
94
|
+
expect(core.vportManager.dxf).toHaveBeenCalledWith(file);
|
|
95
|
+
expect(core.viewManager.dxf).toHaveBeenCalledWith(file);
|
|
96
|
+
expect(core.ucsManager.dxf).toHaveBeenCalledWith(file);
|
|
97
|
+
expect(core.appIdManager.dxf).toHaveBeenCalledWith(file);
|
|
98
|
+
expect(core.blockRecordManager.dxf).toHaveBeenCalledWith(file);
|
|
99
|
+
|
|
100
|
+
expect(file.contents).toContain('0\nSECTION\n2\nTABLES\n');
|
|
101
|
+
expect(file.contents).toContain('0\nENDSEC\n');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('Test DXFWriter.writeBlocks', () => {
|
|
105
|
+
const blockA = { dxf: jest.fn() };
|
|
106
|
+
const blockB = { dxf: jest.fn() };
|
|
107
|
+
const core = createCoreMock({
|
|
108
|
+
blocks: [blockA, blockB],
|
|
109
|
+
});
|
|
110
|
+
DesignCore.Core = core;
|
|
111
|
+
|
|
112
|
+
const writer = new DXFWriter();
|
|
113
|
+
const file = new DXFFile('R2018');
|
|
114
|
+
writer.writeBlocks(file);
|
|
115
|
+
|
|
116
|
+
expect(blockA.dxf).toHaveBeenCalledWith(file);
|
|
117
|
+
expect(blockB.dxf).toHaveBeenCalledWith(file);
|
|
118
|
+
expect(file.contents).toContain('0\nSECTION\n2\nBLOCKS\n');
|
|
119
|
+
expect(file.contents).toContain('0\nENDSEC\n');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
test('Test DXFWriter.writeEntities', () => {
|
|
123
|
+
const entityA = { dxf: jest.fn() };
|
|
124
|
+
const entityB = { dxf: jest.fn() };
|
|
125
|
+
const core = createCoreMock({
|
|
126
|
+
entities: [entityA, entityB],
|
|
127
|
+
});
|
|
128
|
+
DesignCore.Core = core;
|
|
129
|
+
|
|
130
|
+
const writer = new DXFWriter();
|
|
131
|
+
const file = new DXFFile('R2018');
|
|
132
|
+
writer.writeEntities(file);
|
|
133
|
+
|
|
134
|
+
expect(entityA.dxf).toHaveBeenCalledWith(file);
|
|
135
|
+
expect(entityB.dxf).toHaveBeenCalledWith(file);
|
|
136
|
+
expect(file.contents).toContain('0\nSECTION\n2\nENTITIES\n');
|
|
137
|
+
expect(file.contents).toContain('0\nENDSEC\n');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('Test DXFWriter.write default version from core', () => {
|
|
141
|
+
const core = createCoreMock({
|
|
142
|
+
dxfVersion: 'R12',
|
|
143
|
+
});
|
|
144
|
+
DesignCore.Core = core;
|
|
145
|
+
|
|
146
|
+
const writer = new DXFWriter();
|
|
147
|
+
const output = writer.write();
|
|
148
|
+
|
|
149
|
+
expect(output).toContain('999\nDXF created from Design-Core\n');
|
|
150
|
+
expect(output).toContain('2\nHEADER\n');
|
|
151
|
+
expect(output).toContain('2\nTABLES\n');
|
|
152
|
+
expect(output).toContain('2\nBLOCKS\n');
|
|
153
|
+
expect(output).toContain('2\nENTITIES\n');
|
|
154
|
+
expect(output).toContain('0\nEOF\n');
|
|
155
|
+
|
|
156
|
+
expect(output).not.toContain('2\nOBJECTS\n');
|
|
157
|
+
expect(output).not.toContain('0\nDICTIONARY\n');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test('Test DXFWriter.write supports explicit version', () => {
|
|
161
|
+
const core = createCoreMock({
|
|
162
|
+
dxfVersion: 'R12',
|
|
163
|
+
});
|
|
164
|
+
DesignCore.Core = core;
|
|
165
|
+
|
|
166
|
+
const writer = new DXFWriter();
|
|
167
|
+
const output = writer.write('R2018');
|
|
168
|
+
|
|
169
|
+
expect(output).toContain('2\nOBJECTS\n');
|
|
170
|
+
expect(core.dictionaryManager.dxf).toHaveBeenCalled();
|
|
171
|
+
expect(output).toContain('0\nEOF\n');
|
|
172
|
+
});
|
|
173
|
+
});
|