2022-07-23 16:55:02 +00:00
|
|
|
import assert from 'assert'
|
2022-08-05 12:48:57 +00:00
|
|
|
import {dependencyExtractor} from '../../src/core/extractors.mjs'
|
2022-07-23 16:55:02 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|