From 32dcda36b7a0f112a83557971082baa3f5844715 Mon Sep 17 00:00:00 2001 From: Adam Chalmers Date: Wed, 26 Feb 2025 21:35:40 -0600 Subject: [PATCH] Update tests that still use positional data Cases where the application/library code was correct, but the test code was wrong. --- src/lang/queryAst.test.ts | 2 +- src/lang/std/sketch.test.ts | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/lang/queryAst.test.ts b/src/lang/queryAst.test.ts index 82403c33d4..7bc5325371 100644 --- a/src/lang/queryAst.test.ts +++ b/src/lang/queryAst.test.ts @@ -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') diff --git a/src/lang/std/sketch.test.ts b/src/lang/std/sketch.test.ts index 0b4fb7d09c..fac6ee626f 100644 --- a/src/lang/std/sketch.test.ts +++ b/src/lang/std/sketch.test.ts @@ -431,7 +431,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'xLineTo', + 'xLine(endAbsolute', [ { type: 'horizontal', @@ -454,7 +454,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'yLineTo', + 'yLine(endAbsolute', [ { type: 'vertical', @@ -477,7 +477,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'yLine(', + 'yLine(length', [ { type: 'vertical', @@ -500,7 +500,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'xLine(', + 'xLine(length', [ { type: 'horizontal', @@ -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>( @@ -950,7 +949,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'xLineTo', + 'xLine(endAbsolute', [ { type: 'horizontal', @@ -1019,7 +1018,7 @@ describe('testing getConstraintInfo', () => { ], ], [ - 'xLine(', + 'xLine(length', [ { type: 'horizontal',