Fix up tests
This commit is contained in:
		| @ -169,16 +169,24 @@ describe('testing function declaration', () => { | ||||
|               end: 39, | ||||
|               params: [ | ||||
|                 { | ||||
|                   type: 'Identifier', | ||||
|                   start: 12, | ||||
|                   end: 13, | ||||
|                   name: 'a', | ||||
|                   type: 'Parameter', | ||||
|                   identifier: { | ||||
|                     type: 'Identifier', | ||||
|                     start: 12, | ||||
|                     end: 13, | ||||
|                     name: 'a', | ||||
|                   }, | ||||
|                   optional: false, | ||||
|                 }, | ||||
|                 { | ||||
|                   type: 'Identifier', | ||||
|                   start: 15, | ||||
|                   end: 16, | ||||
|                   name: 'b', | ||||
|                   type: 'Parameter', | ||||
|                   identifier: { | ||||
|                     type: 'Identifier', | ||||
|                     start: 15, | ||||
|                     end: 16, | ||||
|                     name: 'b', | ||||
|                   }, | ||||
|                   optional: false, | ||||
|                 }, | ||||
|               ], | ||||
|               body: { | ||||
| @ -244,16 +252,24 @@ const myVar = funcN(1, 2)` | ||||
|               end: 37, | ||||
|               params: [ | ||||
|                 { | ||||
|                   type: 'Identifier', | ||||
|                   start: 12, | ||||
|                   end: 13, | ||||
|                   name: 'a', | ||||
|                   type: 'Parameter', | ||||
|                   identifier: { | ||||
|                     type: 'Identifier', | ||||
|                     start: 12, | ||||
|                     end: 13, | ||||
|                     name: 'a', | ||||
|                   }, | ||||
|                   optional: false, | ||||
|                 }, | ||||
|                 { | ||||
|                   type: 'Identifier', | ||||
|                   start: 15, | ||||
|                   end: 16, | ||||
|                   name: 'b', | ||||
|                   type: 'Parameter', | ||||
|                   identifier: { | ||||
|                     type: 'Identifier', | ||||
|                     start: 15, | ||||
|                     end: 16, | ||||
|                     name: 'b', | ||||
|                   }, | ||||
|                   optional: false, | ||||
|                 }, | ||||
|               ], | ||||
|               body: { | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| import { getNodePathFromSourceRange, getNodeFromPath } from './queryAst' | ||||
| import { Identifier, parse, initPromise } from './wasm' | ||||
| import { Identifier, parse, initPromise, Parameter } from './wasm' | ||||
|  | ||||
| beforeAll(() => initPromise) | ||||
|  | ||||
| @ -46,7 +46,7 @@ const b1 = cube([0,0], 10)` | ||||
|  | ||||
|     const ast = parse(code) | ||||
|     const nodePath = getNodePathFromSourceRange(ast, sourceRange) | ||||
|     const node = getNodeFromPath<Identifier>(ast, nodePath).node | ||||
|     const node = getNodeFromPath<Parameter>(ast, nodePath).node | ||||
|  | ||||
|     expect(nodePath).toEqual([ | ||||
|       ['body', ''], | ||||
| @ -57,8 +57,8 @@ const b1 = cube([0,0], 10)` | ||||
|       ['params', 'FunctionExpression'], | ||||
|       [0, 'index'], | ||||
|     ]) | ||||
|     expect(node.type).toBe('Identifier') | ||||
|     expect(node.name).toBe('pos') | ||||
|     expect(node.type).toBe('Parameter') | ||||
|     expect(node.identifier.name).toBe('pos') | ||||
|   }) | ||||
|   it('gets path right for deep within function definition body', () => { | ||||
|     const code = `fn cube = (pos, scale) => { | ||||
|  | ||||
| @ -20,6 +20,7 @@ export type { ObjectExpression } from '../wasm-lib/kcl/bindings/ObjectExpression | ||||
| export type { MemberExpression } from '../wasm-lib/kcl/bindings/MemberExpression' | ||||
| export type { PipeExpression } from '../wasm-lib/kcl/bindings/PipeExpression' | ||||
| export type { VariableDeclaration } from '../wasm-lib/kcl/bindings/VariableDeclaration' | ||||
| export type { Parameter } from '../wasm-lib/kcl/bindings/Parameter' | ||||
| export type { PipeSubstitution } from '../wasm-lib/kcl/bindings/PipeSubstitution' | ||||
| export type { Identifier } from '../wasm-lib/kcl/bindings/Identifier' | ||||
| export type { UnaryExpression } from '../wasm-lib/kcl/bindings/UnaryExpression' | ||||
|  | ||||
		Reference in New Issue
	
	Block a user