pocomath/test/core/dependencyExtractor.mjs
Glen Whitney e82bcf5a9c refactor: Include more code that should work for instantiating type templates
In particular, there is now an empty stub for the function that actually
  installs the instantiations into the PocomathInstance
2022-08-03 17:55:53 -07:00

23 lines
686 B
JavaScript

import assert from 'assert'
import {dependencyExtractor} from '../../src/core/extractors.mjs'
describe('dependencyExtractor', () => {
it('will record the keys of a destructuring function', () => {
const myfunc = ({a, 'b(x)': b, c: alias}) => 0
const params = new Set()
myfunc(dependencyExtractor(params))
assert.ok(params.has('a'))
assert.ok(params.has('b(x)'))
assert.ok(params.has('c'))
assert.ok(params.size === 3)
})
it('does not pick up anything from a regular function', () => {
const myfunc = arg => 0
const params = new Set()
myfunc(dependencyExtractor(params))
assert.ok(params.size === 0)
})
})