Skip to content

Commit

Permalink
Update tests that still use positional data
Browse files Browse the repository at this point in the history
Cases where the application/library code was correct, but the test code
was wrong.
  • Loading branch information
adamchalmers committed Feb 27, 2025
1 parent 83008f8 commit 32dcda3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/lang/queryAst.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ describe('Testing specific sketch getNodeFromPath workflow', () => {
|> line([-0.08, 0.05], %)`
const ast = assertParse(openSketch)
expect(ast.start).toEqual(0)
expect(ast.end).toEqual(227)
expect(ast.end).toEqual(245)
})
it('should find the location to add new lineTo', () => {
const openSketch = `sketch001 = startSketchOn('XZ')
Expand Down
19 changes: 9 additions & 10 deletions src/lang/std/sketch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'xLineTo',
'xLine(endAbsolute',
[
{
type: 'horizontal',
Expand All @@ -454,7 +454,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'yLineTo',
'yLine(endAbsolute',
[
{
type: 'vertical',
Expand All @@ -477,7 +477,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'yLine(',
'yLine(length',
[
{
type: 'vertical',
Expand All @@ -500,7 +500,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'xLine(',
'xLine(length',
[
{
type: 'horizontal',
Expand Down Expand Up @@ -683,10 +683,9 @@ describe('testing getConstraintInfo', () => {
],
])('testing %s when inputs are unconstrained', (functionName, expected) => {
const ast = assertParse(code)
const sourceRange = topLevelRange(
code.indexOf(functionName),
code.indexOf(functionName) + functionName.length
)
const start = code.indexOf(functionName)
expect(start).toBeGreaterThanOrEqual(0)
const sourceRange = topLevelRange(start, start + functionName.length)
if (err(ast)) return ast
const pathToNode = getNodePathFromSourceRange(ast, sourceRange)
const callExp = getNodeFromPath<Node<CallExpression | CallExpressionKw>>(
Expand Down Expand Up @@ -950,7 +949,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'xLineTo',
'xLine(endAbsolute',
[
{
type: 'horizontal',
Expand Down Expand Up @@ -1019,7 +1018,7 @@ describe('testing getConstraintInfo', () => {
],
],
[
'xLine(',
'xLine(length',
[
{
type: 'horizontal',
Expand Down

0 comments on commit 32dcda3

Please sign in to comment.