wyreframe 0.1.0 → 0.1.5
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/LICENSE +692 -0
- package/README.md +65 -5
- package/package.json +8 -7
- package/src/index.ts +425 -0
- package/src/renderer/Renderer.gen.tsx +49 -0
- package/src/renderer/Renderer.mjs +41 -1
- package/src/renderer/Renderer.res +78 -0
- package/src/parser/Core/__tests__/Bounds_test.mjs +0 -326
- package/src/parser/Core/__tests__/Bounds_test.res +0 -412
- package/src/parser/Core/__tests__/Grid_test.mjs +0 -322
- package/src/parser/Core/__tests__/Grid_test.res +0 -319
- package/src/parser/Core/__tests__/Types_test.mjs +0 -614
- package/src/parser/Core/__tests__/Types_test.res +0 -650
- package/src/parser/Detector/__tests__/BoxTracer_test.mjs +0 -70
- package/src/parser/Detector/__tests__/BoxTracer_test.res +0 -92
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.mjs +0 -489
- package/src/parser/Detector/__tests__/HierarchyBuilder_test.res +0 -849
- package/src/parser/Detector/__tests__/ShapeDetector_test.mjs +0 -377
- package/src/parser/Detector/__tests__/ShapeDetector_test.res +0 -563
- package/src/parser/Interactions/__tests__/InteractionMerger_test.mjs +0 -576
- package/src/parser/Interactions/__tests__/InteractionMerger_test.res +0 -646
- package/src/parser/Scanner/__tests__/Grid_manual.mjs +0 -214
- package/src/parser/Scanner/__tests__/Grid_manual.res +0 -141
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.mjs +0 -189
- package/src/parser/Semantic/Elements/__tests__/ButtonParser_test.res +0 -257
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.mjs +0 -202
- package/src/parser/Semantic/Elements/__tests__/CheckboxParser_test.res +0 -250
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.mjs +0 -293
- package/src/parser/Semantic/Elements/__tests__/CodeTextParser_manual.res +0 -134
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.mjs +0 -253
- package/src/parser/Semantic/Elements/__tests__/InputParser_test.res +0 -304
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.mjs +0 -289
- package/src/parser/Semantic/Elements/__tests__/LinkParser_test.res +0 -402
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.mjs +0 -149
- package/src/parser/Semantic/Elements/__tests__/TextParser_test.res +0 -167
- package/src/parser/Semantic/__tests__/ASTBuilder_test.mjs +0 -187
- package/src/parser/Semantic/__tests__/ASTBuilder_test.res +0 -192
- package/src/parser/Semantic/__tests__/ParserRegistry_test.mjs +0 -154
- package/src/parser/Semantic/__tests__/ParserRegistry_test.res +0 -191
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.mjs +0 -768
- package/src/parser/Semantic/__tests__/SemanticParser_integration_test.res +0 -1069
- package/src/parser/Semantic/__tests__/SemanticParser_manual.mjs +0 -1329
- package/src/parser/Semantic/__tests__/SemanticParser_manual.res +0 -544
- package/src/parser/__tests__/GridScanner_integration.test.mjs +0 -632
- package/src/parser/__tests__/GridScanner_integration.test.res +0 -816
- package/src/parser/__tests__/Performance.test.mjs +0 -244
- package/src/parser/__tests__/Performance.test.res +0 -371
- package/src/parser/__tests__/PerformanceFixtures.mjs +0 -200
- package/src/parser/__tests__/PerformanceFixtures.res +0 -284
- package/src/parser/__tests__/WyreframeParser_integration.test.mjs +0 -770
- package/src/parser/__tests__/WyreframeParser_integration.test.res +0 -1008
- package/src/parser/__tests__/fixtures/alignment-test.txt +0 -9
- package/src/parser/__tests__/fixtures/all-elements.txt +0 -16
- package/src/parser/__tests__/fixtures/login-scene.txt +0 -17
- package/src/parser/__tests__/fixtures/multi-scene.txt +0 -25
- package/src/parser/__tests__/fixtures/nested-boxes.txt +0 -15
- package/src/parser/__tests__/fixtures/simple-box.txt +0 -5
- package/src/parser/__tests__/fixtures/with-dividers.txt +0 -14
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Grid from "../../Core/Grid.mjs";
|
|
4
|
-
import * as Types from "../../Core/Types.mjs";
|
|
5
|
-
import * as Core__Array from "@rescript/core/src/Core__Array.mjs";
|
|
6
|
-
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
7
|
-
|
|
8
|
-
function check(condition, message) {
|
|
9
|
-
if (condition) {
|
|
10
|
-
console.log("✓ PASS: " + message);
|
|
11
|
-
} else {
|
|
12
|
-
console.error("✗ FAIL: " + message);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function assertEqual(actual, expected, message) {
|
|
17
|
-
if (Primitive_object.equal(actual, expected)) {
|
|
18
|
-
console.log("✓ PASS: " + message);
|
|
19
|
-
} else {
|
|
20
|
-
console.error("✗ FAIL: " + message);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
console.log("\n=== Grid Construction Tests ===\n");
|
|
25
|
-
|
|
26
|
-
let lines1 = [
|
|
27
|
-
"abc",
|
|
28
|
-
"def",
|
|
29
|
-
"ghi"
|
|
30
|
-
];
|
|
31
|
-
|
|
32
|
-
let grid1 = Grid.fromLines(lines1);
|
|
33
|
-
|
|
34
|
-
assertEqual(grid1.width, 3, "Grid width for uniform lines");
|
|
35
|
-
|
|
36
|
-
assertEqual(grid1.height, 3, "Grid height for uniform lines");
|
|
37
|
-
|
|
38
|
-
let lines2 = [
|
|
39
|
-
"abc",
|
|
40
|
-
"de",
|
|
41
|
-
"f"
|
|
42
|
-
];
|
|
43
|
-
|
|
44
|
-
let grid2 = Grid.fromLines(lines2);
|
|
45
|
-
|
|
46
|
-
assertEqual(grid2.width, 3, "Grid width after normalization");
|
|
47
|
-
|
|
48
|
-
assertEqual(grid2.height, 3, "Grid height after normalization");
|
|
49
|
-
|
|
50
|
-
let lines3 = [
|
|
51
|
-
"+--+",
|
|
52
|
-
"| |",
|
|
53
|
-
"+--+"
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
let grid3 = Grid.fromLines(lines3);
|
|
57
|
-
|
|
58
|
-
assertEqual(grid3.cornerIndex.length, 4, "Corner index count");
|
|
59
|
-
|
|
60
|
-
assertEqual(grid3.hLineIndex.length, 4, "HLine index count");
|
|
61
|
-
|
|
62
|
-
assertEqual(grid3.vLineIndex.length, 2, "VLine index count");
|
|
63
|
-
|
|
64
|
-
console.log("\n=== Character Access Tests ===\n");
|
|
65
|
-
|
|
66
|
-
let match = Grid.get(grid3, Types.Position.make(0, 0));
|
|
67
|
-
|
|
68
|
-
if (match === "Corner" && typeof match !== "object") {
|
|
69
|
-
console.log("✓ PASS: Get character at (0,0) returns Corner");
|
|
70
|
-
} else {
|
|
71
|
-
console.error("✗ FAIL: Get character at (0,0) should return Corner");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let match$1 = Grid.get(grid3, Types.Position.make(10, 10));
|
|
75
|
-
|
|
76
|
-
if (match$1 !== undefined) {
|
|
77
|
-
console.error("✗ FAIL: Get character out of bounds should return None");
|
|
78
|
-
} else {
|
|
79
|
-
console.log("✓ PASS: Get character out of bounds returns None");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
let line = Grid.getLine(grid3, 0);
|
|
83
|
-
|
|
84
|
-
if (line !== undefined) {
|
|
85
|
-
assertEqual(line.length, 4, "Get line returns correct length");
|
|
86
|
-
} else {
|
|
87
|
-
console.error("✗ FAIL: Get line should return Some");
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
console.log("\n=== Directional Scanning Tests ===\n");
|
|
91
|
-
|
|
92
|
-
let scanResults = Grid.scanRight(grid3, Types.Position.make(0, 0), cell => {
|
|
93
|
-
if (typeof cell === "object") {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
switch (cell) {
|
|
97
|
-
case "Corner" :
|
|
98
|
-
case "HLine" :
|
|
99
|
-
return true;
|
|
100
|
-
default:
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
assertEqual(scanResults.length, 4, "Scan right collects correct number of characters");
|
|
106
|
-
|
|
107
|
-
let scanDownResults = Grid.scanDown(grid3, Types.Position.make(0, 0), cell => {
|
|
108
|
-
if (typeof cell === "object") {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
switch (cell) {
|
|
112
|
-
case "Corner" :
|
|
113
|
-
case "VLine" :
|
|
114
|
-
return true;
|
|
115
|
-
default:
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
assertEqual(scanDownResults.length, 3, "Scan down collects correct number of characters");
|
|
121
|
-
|
|
122
|
-
console.log("\n=== Search Operations Tests ===\n");
|
|
123
|
-
|
|
124
|
-
let allCorners = Grid.findAll(grid3, "Corner");
|
|
125
|
-
|
|
126
|
-
assertEqual(allCorners.length, 4, "Find all corners returns 4 positions");
|
|
127
|
-
|
|
128
|
-
let bounds = Types.Bounds.make(0, 0, 1, 2);
|
|
129
|
-
|
|
130
|
-
let cornersInRange = Grid.findInRange(grid3, "Corner", bounds);
|
|
131
|
-
|
|
132
|
-
assertEqual(cornersInRange.length, 1, "Find in range returns corners within bounds");
|
|
133
|
-
|
|
134
|
-
console.log("\n=== Performance Tests ===\n");
|
|
135
|
-
|
|
136
|
-
let largeLines = Core__Array.make(1000, "+".repeat(100));
|
|
137
|
-
|
|
138
|
-
let startTime = Date.now();
|
|
139
|
-
|
|
140
|
-
let largeGrid = Grid.fromLines(largeLines);
|
|
141
|
-
|
|
142
|
-
let endTime = Date.now();
|
|
143
|
-
|
|
144
|
-
let duration = endTime - startTime;
|
|
145
|
-
|
|
146
|
-
assertEqual(largeGrid.height, 1000, "Large grid has correct height");
|
|
147
|
-
|
|
148
|
-
assertEqual(largeGrid.width, 100, "Large grid has correct width");
|
|
149
|
-
|
|
150
|
-
check(duration < 10.0, `Grid construction <10ms (actual: ` + duration.toString() + `ms)`);
|
|
151
|
-
|
|
152
|
-
let findStartTime = Date.now();
|
|
153
|
-
|
|
154
|
-
let _corners = Grid.findAll(largeGrid, "Corner");
|
|
155
|
-
|
|
156
|
-
let findEndTime = Date.now();
|
|
157
|
-
|
|
158
|
-
let findDuration = findEndTime - findStartTime;
|
|
159
|
-
|
|
160
|
-
check(findDuration < 5.0, `Finding all corners using index <5ms (actual: ` + findDuration.toString() + `ms)`);
|
|
161
|
-
|
|
162
|
-
console.log("\n=== Edge Cases Tests ===\n");
|
|
163
|
-
|
|
164
|
-
let singleCharLines = ["+"];
|
|
165
|
-
|
|
166
|
-
let singleCharGrid = Grid.fromLines(singleCharLines);
|
|
167
|
-
|
|
168
|
-
assertEqual(singleCharGrid.width, 1, "Single character grid width");
|
|
169
|
-
|
|
170
|
-
assertEqual(singleCharGrid.height, 1, "Single character grid height");
|
|
171
|
-
|
|
172
|
-
let emptyLines = [
|
|
173
|
-
"",
|
|
174
|
-
"",
|
|
175
|
-
""
|
|
176
|
-
];
|
|
177
|
-
|
|
178
|
-
let emptyGrid = Grid.fromLines(emptyLines);
|
|
179
|
-
|
|
180
|
-
assertEqual(emptyGrid.width, 0, "Empty lines grid width is 0");
|
|
181
|
-
|
|
182
|
-
assertEqual(emptyGrid.height, 3, "Empty lines grid height is 3");
|
|
183
|
-
|
|
184
|
-
console.log("\n=== All Tests Complete ===\n");
|
|
185
|
-
|
|
186
|
-
export {
|
|
187
|
-
check,
|
|
188
|
-
assertEqual,
|
|
189
|
-
lines1,
|
|
190
|
-
grid1,
|
|
191
|
-
lines2,
|
|
192
|
-
grid2,
|
|
193
|
-
lines3,
|
|
194
|
-
grid3,
|
|
195
|
-
scanResults,
|
|
196
|
-
scanDownResults,
|
|
197
|
-
allCorners,
|
|
198
|
-
bounds,
|
|
199
|
-
cornersInRange,
|
|
200
|
-
largeLines,
|
|
201
|
-
startTime,
|
|
202
|
-
largeGrid,
|
|
203
|
-
endTime,
|
|
204
|
-
duration,
|
|
205
|
-
findStartTime,
|
|
206
|
-
_corners,
|
|
207
|
-
findEndTime,
|
|
208
|
-
findDuration,
|
|
209
|
-
singleCharLines,
|
|
210
|
-
singleCharGrid,
|
|
211
|
-
emptyLines,
|
|
212
|
-
emptyGrid,
|
|
213
|
-
}
|
|
214
|
-
/* Not a pure module */
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// Grid_manual_test.res
|
|
2
|
-
// Manual test file for Grid data structure (without Jest)
|
|
3
|
-
// Run with: node src/parser/Scanner/__tests__/Grid_manual_test.mjs
|
|
4
|
-
|
|
5
|
-
open Types
|
|
6
|
-
|
|
7
|
-
// Test helper
|
|
8
|
-
let check = (condition: bool, message: string): unit => {
|
|
9
|
-
if condition {
|
|
10
|
-
Console.log("✓ PASS: " ++ message)
|
|
11
|
-
} else {
|
|
12
|
-
Console.error("✗ FAIL: " ++ message)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let assertEqual = (actual: 'a, expected: 'a, message: string): unit => {
|
|
17
|
-
if actual == expected {
|
|
18
|
-
Console.log("✓ PASS: " ++ message)
|
|
19
|
-
} else {
|
|
20
|
-
Console.error("✗ FAIL: " ++ message)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
Console.log("\n=== Grid Construction Tests ===\n")
|
|
25
|
-
|
|
26
|
-
// Test 1: Basic grid construction
|
|
27
|
-
let lines1 = ["abc", "def", "ghi"]
|
|
28
|
-
let grid1 = Grid.fromLines(lines1)
|
|
29
|
-
assertEqual(grid1.width, 3, "Grid width for uniform lines")
|
|
30
|
-
assertEqual(grid1.height, 3, "Grid height for uniform lines")
|
|
31
|
-
|
|
32
|
-
// Test 2: Normalization of varying length lines
|
|
33
|
-
let lines2 = ["abc", "de", "f"]
|
|
34
|
-
let grid2 = Grid.fromLines(lines2)
|
|
35
|
-
assertEqual(grid2.width, 3, "Grid width after normalization")
|
|
36
|
-
assertEqual(grid2.height, 3, "Grid height after normalization")
|
|
37
|
-
|
|
38
|
-
// Test 3: Character indices
|
|
39
|
-
let lines3 = ["+--+", "| |", "+--+"]
|
|
40
|
-
let grid3 = Grid.fromLines(lines3)
|
|
41
|
-
assertEqual(Array.length(grid3.cornerIndex), 4, "Corner index count")
|
|
42
|
-
assertEqual(Array.length(grid3.hLineIndex), 4, "HLine index count")
|
|
43
|
-
// VLines are only at positions (1,0) and (1,3) in the grid
|
|
44
|
-
assertEqual(Array.length(grid3.vLineIndex), 2, "VLine index count")
|
|
45
|
-
|
|
46
|
-
Console.log("\n=== Character Access Tests ===\n")
|
|
47
|
-
|
|
48
|
-
// Test 4: Get character at position
|
|
49
|
-
switch Grid.get(grid3, Position.make(0, 0)) {
|
|
50
|
-
| Some(Corner) => Console.log("✓ PASS: Get character at (0,0) returns Corner")
|
|
51
|
-
| _ => Console.error("✗ FAIL: Get character at (0,0) should return Corner")
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Test 5: Get out of bounds
|
|
55
|
-
switch Grid.get(grid3, Position.make(10, 10)) {
|
|
56
|
-
| None => Console.log("✓ PASS: Get character out of bounds returns None")
|
|
57
|
-
| _ => Console.error("✗ FAIL: Get character out of bounds should return None")
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Test 6: Get line
|
|
61
|
-
switch Grid.getLine(grid3, 0) {
|
|
62
|
-
| Some(line) => assertEqual(Array.length(line), 4, "Get line returns correct length")
|
|
63
|
-
| None => Console.error("✗ FAIL: Get line should return Some")
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
Console.log("\n=== Directional Scanning Tests ===\n")
|
|
67
|
-
|
|
68
|
-
// Test 7: Scan right
|
|
69
|
-
let scanResults = Grid.scanRight(grid3, Position.make(0, 0), cell => {
|
|
70
|
-
switch cell {
|
|
71
|
-
| Corner | HLine => true
|
|
72
|
-
| _ => false
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
assertEqual(Array.length(scanResults), 4, "Scan right collects correct number of characters")
|
|
76
|
-
|
|
77
|
-
// Test 8: Scan down
|
|
78
|
-
let scanDownResults = Grid.scanDown(grid3, Position.make(0, 0), cell => {
|
|
79
|
-
switch cell {
|
|
80
|
-
| Corner | VLine => true
|
|
81
|
-
| _ => false
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
assertEqual(Array.length(scanDownResults), 3, "Scan down collects correct number of characters")
|
|
85
|
-
|
|
86
|
-
Console.log("\n=== Search Operations Tests ===\n")
|
|
87
|
-
|
|
88
|
-
// Test 9: Find all corners
|
|
89
|
-
let allCorners = Grid.findAll(grid3, Corner)
|
|
90
|
-
assertEqual(Array.length(allCorners), 4, "Find all corners returns 4 positions")
|
|
91
|
-
|
|
92
|
-
// Test 10: Find in range
|
|
93
|
-
// Grid corners are at (0,0), (0,3), (2,0), (2,3)
|
|
94
|
-
// With bounds top=0, left=0, bottom=1, right=2, only (0,0) is within range
|
|
95
|
-
let bounds = Bounds.make(~top=0, ~left=0, ~bottom=1, ~right=2)
|
|
96
|
-
let cornersInRange = Grid.findInRange(grid3, Corner, bounds)
|
|
97
|
-
assertEqual(
|
|
98
|
-
Array.length(cornersInRange),
|
|
99
|
-
1,
|
|
100
|
-
"Find in range returns corners within bounds",
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
Console.log("\n=== Performance Tests ===\n")
|
|
104
|
-
|
|
105
|
-
// Test 11: Large grid performance
|
|
106
|
-
let largeLines = Array.make(~length=1000, "+"->String.repeat(100))
|
|
107
|
-
let startTime = Date.now()
|
|
108
|
-
let largeGrid = Grid.fromLines(largeLines)
|
|
109
|
-
let endTime = Date.now()
|
|
110
|
-
let duration = endTime -. startTime
|
|
111
|
-
|
|
112
|
-
assertEqual(largeGrid.height, 1000, "Large grid has correct height")
|
|
113
|
-
assertEqual(largeGrid.width, 100, "Large grid has correct width")
|
|
114
|
-
check(duration < 10.0, `Grid construction <10ms (actual: ${Float.toString(duration)}ms)`)
|
|
115
|
-
|
|
116
|
-
// Test 12: Index lookup performance
|
|
117
|
-
let findStartTime = Date.now()
|
|
118
|
-
let _corners = Grid.findAll(largeGrid, Corner)
|
|
119
|
-
let findEndTime = Date.now()
|
|
120
|
-
let findDuration = findEndTime -. findStartTime
|
|
121
|
-
|
|
122
|
-
check(
|
|
123
|
-
findDuration < 5.0,
|
|
124
|
-
`Finding all corners using index <5ms (actual: ${Float.toString(findDuration)}ms)`,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
Console.log("\n=== Edge Cases Tests ===\n")
|
|
128
|
-
|
|
129
|
-
// Test 15: Single character grid
|
|
130
|
-
let singleCharLines = ["+"]
|
|
131
|
-
let singleCharGrid = Grid.fromLines(singleCharLines)
|
|
132
|
-
assertEqual(singleCharGrid.width, 1, "Single character grid width")
|
|
133
|
-
assertEqual(singleCharGrid.height, 1, "Single character grid height")
|
|
134
|
-
|
|
135
|
-
// Test 16: Empty lines
|
|
136
|
-
let emptyLines = ["", "", ""]
|
|
137
|
-
let emptyGrid = Grid.fromLines(emptyLines)
|
|
138
|
-
assertEqual(emptyGrid.width, 0, "Empty lines grid width is 0")
|
|
139
|
-
assertEqual(emptyGrid.height, 3, "Empty lines grid height is 3")
|
|
140
|
-
|
|
141
|
-
Console.log("\n=== All Tests Complete ===\n")
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Types from "../../../Core/Types.mjs";
|
|
4
|
-
import * as Vitest from "rescript-vitest/src/Vitest.mjs";
|
|
5
|
-
import * as ButtonParser from "../ButtonParser.mjs";
|
|
6
|
-
|
|
7
|
-
Vitest.describe("ButtonParser", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
|
|
8
|
-
let testPosition = Types.Position.make(5, 10);
|
|
9
|
-
let testBounds = {
|
|
10
|
-
top: 0,
|
|
11
|
-
left: 0,
|
|
12
|
-
bottom: 10,
|
|
13
|
-
right: 30
|
|
14
|
-
};
|
|
15
|
-
Vitest.describe("slugify", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
|
|
16
|
-
Vitest.test("converts simple text to lowercase with hyphens", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("Submit Form")).toBe("submit-form"));
|
|
17
|
-
Vitest.test("handles single words", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("Login")).toBe("login"));
|
|
18
|
-
Vitest.test("removes special characters", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("Create Account!")).toBe("create-account"));
|
|
19
|
-
Vitest.test("handles multiple spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("Log In")).toBe("log-in"));
|
|
20
|
-
Vitest.test("removes leading and trailing spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify(" Cancel ")).toBe("cancel"));
|
|
21
|
-
Vitest.test("handles mixed case", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("SAVE Changes")).toBe("save-changes"));
|
|
22
|
-
Vitest.test("removes consecutive hyphens", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.slugify("Submit--Form")).toBe("submit-form"));
|
|
23
|
-
});
|
|
24
|
-
Vitest.describe("canParse", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
|
|
25
|
-
Vitest.test("returns true for basic button syntax", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("[ Submit ]")).toBe(true));
|
|
26
|
-
Vitest.test("returns true for button without spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("[Login]")).toBe(true));
|
|
27
|
-
Vitest.test("returns true for button with extra whitespace", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("[ Create Account ]")).toBe(true));
|
|
28
|
-
Vitest.test("returns true for multiword button", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("[ Log In ]")).toBe(true));
|
|
29
|
-
Vitest.test("returns false for text without brackets", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("Submit")).toBe(false));
|
|
30
|
-
Vitest.test("returns false for only opening bracket", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("[ Submit")).toBe(false));
|
|
31
|
-
Vitest.test("returns false for only closing bracket", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("Submit ]")).toBe(false));
|
|
32
|
-
Vitest.test("returns false for empty string", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("")).toBe(false));
|
|
33
|
-
Vitest.test("returns true for button with content before/after", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => t.expect(ButtonParser.canParse("Click [ Submit ] to continue")).toBe(true));
|
|
34
|
-
});
|
|
35
|
-
Vitest.describe("parse", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
|
|
36
|
-
Vitest.test("parses basic button correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
37
|
-
let result = ButtonParser.parse("[ Submit ]", testPosition, testBounds);
|
|
38
|
-
if (result === undefined) {
|
|
39
|
-
return t.expect(true).toBe(false);
|
|
40
|
-
}
|
|
41
|
-
if (result.TAG !== "Button") {
|
|
42
|
-
return t.expect(true).toBe(false);
|
|
43
|
-
}
|
|
44
|
-
t.expect(result.id).toBe("submit");
|
|
45
|
-
t.expect(result.text).toBe("Submit");
|
|
46
|
-
t.expect(result.position).toEqual(testPosition);
|
|
47
|
-
t.expect(result.align).toEqual("Center");
|
|
48
|
-
});
|
|
49
|
-
Vitest.test("parses button without spaces", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
50
|
-
let result = ButtonParser.parse("[Login]", testPosition, testBounds);
|
|
51
|
-
if (result === undefined) {
|
|
52
|
-
return t.expect(true).toBe(false);
|
|
53
|
-
}
|
|
54
|
-
if (result.TAG !== "Button") {
|
|
55
|
-
return t.expect(true).toBe(false);
|
|
56
|
-
}
|
|
57
|
-
t.expect(result.id).toBe("login");
|
|
58
|
-
t.expect(result.text).toBe("Login");
|
|
59
|
-
});
|
|
60
|
-
Vitest.test("parses button with extra whitespace", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
61
|
-
let result = ButtonParser.parse("[ Create Account ]", testPosition, testBounds);
|
|
62
|
-
if (result === undefined) {
|
|
63
|
-
return t.expect(true).toBe(false);
|
|
64
|
-
}
|
|
65
|
-
if (result.TAG !== "Button") {
|
|
66
|
-
return t.expect(true).toBe(false);
|
|
67
|
-
}
|
|
68
|
-
t.expect(result.id).toBe("create-account");
|
|
69
|
-
t.expect(result.text).toBe("Create Account");
|
|
70
|
-
});
|
|
71
|
-
Vitest.test("parses multiword button text", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
72
|
-
let result = ButtonParser.parse("[ Log In ]", testPosition, testBounds);
|
|
73
|
-
if (result === undefined) {
|
|
74
|
-
return t.expect(true).toBe(false);
|
|
75
|
-
}
|
|
76
|
-
if (result.TAG !== "Button") {
|
|
77
|
-
return t.expect(true).toBe(false);
|
|
78
|
-
}
|
|
79
|
-
t.expect(result.id).toBe("log-in");
|
|
80
|
-
t.expect(result.text).toBe("Log In");
|
|
81
|
-
});
|
|
82
|
-
Vitest.test("trims leading and trailing whitespace from button text", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
83
|
-
let result = ButtonParser.parse("[ Cancel ]", testPosition, testBounds);
|
|
84
|
-
if (result === undefined) {
|
|
85
|
-
return t.expect(true).toBe(false);
|
|
86
|
-
}
|
|
87
|
-
if (result.TAG !== "Button") {
|
|
88
|
-
return t.expect(true).toBe(false);
|
|
89
|
-
}
|
|
90
|
-
t.expect(result.text).toBe("Cancel");
|
|
91
|
-
t.expect(result.id).toBe("cancel");
|
|
92
|
-
});
|
|
93
|
-
Vitest.test("returns None for empty button text", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
94
|
-
let result = ButtonParser.parse("[ ]", testPosition, testBounds);
|
|
95
|
-
t.expect(result).toEqual(undefined);
|
|
96
|
-
});
|
|
97
|
-
Vitest.test("returns None for button with only whitespace", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
98
|
-
let result = ButtonParser.parse("[ ]", testPosition, testBounds);
|
|
99
|
-
t.expect(result).toEqual(undefined);
|
|
100
|
-
});
|
|
101
|
-
Vitest.test("returns None for text without brackets", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
102
|
-
let result = ButtonParser.parse("Submit", testPosition, testBounds);
|
|
103
|
-
t.expect(result).toEqual(undefined);
|
|
104
|
-
});
|
|
105
|
-
Vitest.test("returns None for incomplete button syntax (missing closing bracket)", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
106
|
-
let result = ButtonParser.parse("[ Submit", testPosition, testBounds);
|
|
107
|
-
t.expect(result).toEqual(undefined);
|
|
108
|
-
});
|
|
109
|
-
Vitest.test("returns None for incomplete button syntax (missing opening bracket)", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
110
|
-
let result = ButtonParser.parse("Submit ]", testPosition, testBounds);
|
|
111
|
-
t.expect(result).toEqual(undefined);
|
|
112
|
-
});
|
|
113
|
-
Vitest.test("handles button with special characters in text", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
114
|
-
let result = ButtonParser.parse("[ Save & Exit ]", testPosition, testBounds);
|
|
115
|
-
if (result === undefined) {
|
|
116
|
-
return t.expect(true).toBe(false);
|
|
117
|
-
}
|
|
118
|
-
if (result.TAG !== "Button") {
|
|
119
|
-
return t.expect(true).toBe(false);
|
|
120
|
-
}
|
|
121
|
-
t.expect(result.text).toBe("Save & Exit");
|
|
122
|
-
t.expect(result.id).toBe("save-exit");
|
|
123
|
-
});
|
|
124
|
-
Vitest.test("handles button with numbers", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
125
|
-
let result = ButtonParser.parse("[ Option 1 ]", testPosition, testBounds);
|
|
126
|
-
if (result === undefined) {
|
|
127
|
-
return t.expect(true).toBe(false);
|
|
128
|
-
}
|
|
129
|
-
if (result.TAG !== "Button") {
|
|
130
|
-
return t.expect(true).toBe(false);
|
|
131
|
-
}
|
|
132
|
-
t.expect(result.text).toBe("Option 1");
|
|
133
|
-
t.expect(result.id).toBe("option-1");
|
|
134
|
-
});
|
|
135
|
-
Vitest.test("preserves position in parsed element", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
136
|
-
let customPosition = Types.Position.make(3, 7);
|
|
137
|
-
let result = ButtonParser.parse("[ Test ]", customPosition, testBounds);
|
|
138
|
-
if (result !== undefined && result.TAG === "Button") {
|
|
139
|
-
return t.expect(result.position).toEqual(customPosition);
|
|
140
|
-
} else {
|
|
141
|
-
return t.expect(true).toBe(false);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
Vitest.test("returns None for content with extra text before button", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
145
|
-
let result = ButtonParser.parse("Click [ Submit ] here", testPosition, testBounds);
|
|
146
|
-
t.expect(result).toEqual(undefined);
|
|
147
|
-
});
|
|
148
|
-
Vitest.test("handles nested brackets by matching outer brackets", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
149
|
-
let result = ButtonParser.parse("[ [nested] ]", testPosition, testBounds);
|
|
150
|
-
if (result === undefined) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (result.TAG === "Button") {
|
|
154
|
-
return t.expect(result.text).toBe("[nested]");
|
|
155
|
-
}
|
|
156
|
-
throw {
|
|
157
|
-
RE_EXN_ID: "Match_failure",
|
|
158
|
-
_1: [
|
|
159
|
-
"ButtonParser_test.res",
|
|
160
|
-
221,
|
|
161
|
-
6
|
|
162
|
-
],
|
|
163
|
-
Error: new Error()
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
Vitest.describe("make", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, () => {
|
|
168
|
-
Vitest.test("creates parser with priority 100", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
169
|
-
let parser = ButtonParser.make();
|
|
170
|
-
t.expect(parser.priority).toBe(100);
|
|
171
|
-
});
|
|
172
|
-
Vitest.test("created parser can parse buttons", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
173
|
-
let parser = ButtonParser.make();
|
|
174
|
-
let result = parser.parse("[ Test ]", testPosition, testBounds);
|
|
175
|
-
if (result !== undefined && result.TAG === "Button") {
|
|
176
|
-
return;
|
|
177
|
-
} else {
|
|
178
|
-
return t.expect(true).toBe(false);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
Vitest.test("created parser canParse works correctly", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, t => {
|
|
182
|
-
let parser = ButtonParser.make();
|
|
183
|
-
t.expect(parser.canParse("[ Button ]")).toBe(true);
|
|
184
|
-
t.expect(parser.canParse("Not a button")).toBe(false);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
/* Not a pure module */
|