Update tests that still use positional data
Cases where the application/library code was correct, but the test code was wrong.
This commit is contained in:
@ -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')
|
||||
|
||||
@ -431,12 +431,12 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'xLineTo',
|
||||
'xLine(endAbsolute',
|
||||
[
|
||||
{
|
||||
type: 'horizontal',
|
||||
isConstrained: true,
|
||||
value: 'xLineTo',
|
||||
value: 'xLine',
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
argPosition: undefined,
|
||||
pathToNode: expect.any(Array),
|
||||
@ -454,12 +454,12 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'yLineTo',
|
||||
'yLine(endAbsolute',
|
||||
[
|
||||
{
|
||||
type: 'vertical',
|
||||
isConstrained: true,
|
||||
value: 'yLineTo',
|
||||
value: 'yLine',
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
argPosition: undefined,
|
||||
pathToNode: expect.any(Array),
|
||||
@ -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<Node<CallExpression | CallExpressionKw>>(
|
||||
@ -950,12 +949,12 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'xLineTo',
|
||||
'xLine(endAbsolute',
|
||||
[
|
||||
{
|
||||
type: 'horizontal',
|
||||
isConstrained: true,
|
||||
value: 'xLineTo',
|
||||
value: 'xLine',
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
argPosition: undefined,
|
||||
pathToNode: expect.any(Array),
|
||||
@ -973,12 +972,12 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'yLineTo',
|
||||
'yLine(endAbsolute',
|
||||
[
|
||||
{
|
||||
type: 'vertical',
|
||||
isConstrained: true,
|
||||
value: 'yLineTo',
|
||||
value: 'yLine',
|
||||
sourceRange: [expect.any(Number), expect.any(Number), 0],
|
||||
argPosition: undefined,
|
||||
pathToNode: expect.any(Array),
|
||||
@ -996,7 +995,7 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'yLine(',
|
||||
'yLine(length',
|
||||
[
|
||||
{
|
||||
type: 'vertical',
|
||||
@ -1019,7 +1018,7 @@ describe('testing getConstraintInfo', () => {
|
||||
],
|
||||
],
|
||||
[
|
||||
'xLine(',
|
||||
'xLine(length',
|
||||
[
|
||||
{
|
||||
type: 'horizontal',
|
||||
|
||||
@ -2380,7 +2380,19 @@ export function getConstraintInfoKw(
|
||||
fnName === 'circleThreePoint' ||
|
||||
findKwArg('endAbsolute', callExpression) !== undefined
|
||||
if (!(fnName in sketchLineHelperMapKw)) return []
|
||||
const correctFnName = fnName === 'line' && isAbsolute ? 'lineTo' : fnName
|
||||
const correctFnName = (() => {
|
||||
switch (fnName) {
|
||||
case 'line':
|
||||
return isAbsolute ? 'lineTo' : fnName
|
||||
case 'xLine':
|
||||
return isAbsolute ? 'xLineTo' : fnName
|
||||
case 'yLine':
|
||||
return isAbsolute ? 'yLineTo' : fnName
|
||||
}
|
||||
})()
|
||||
if (correctFnName === undefined) {
|
||||
return []
|
||||
}
|
||||
return sketchLineHelperMapKw[correctFnName].getConstraintInfo(
|
||||
callExpression,
|
||||
code,
|
||||
|
||||
Reference in New Issue
Block a user