Skip to content

Commit

Permalink
test: add more edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 13, 2022
1 parent fbc9b5a commit 2184d3b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/imports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { findDynamicImports, findStaticImports, parseStaticImport } from '../src
// -- Static import --

const staticTests = {

'import defaultMember from "module-name";': {
specifier: 'module-name',
defaultImport: 'defaultMember'
Expand Down Expand Up @@ -55,9 +54,18 @@ const staticTests = {
namedImports: { other: 'other' }
}
],
// Edge cases
'"import"===node.object.meta.name&&"': []
}

staticTests[`
Object.freeze(['node', 'import'])
const a = 123
const b = new Set(['node', 'import'])
const c = ['.mjs', '.cjs', '.js', '.json']
`] = []

staticTests[`import {
member1,
// test
Expand Down Expand Up @@ -108,7 +116,7 @@ describe('findStaticImports', () => {
it(input.replace(/\n/g, '\\n'), () => {
const matches = findStaticImports(input)
const results = Array.isArray(_results) ? _results : [_results]
expect(results.length).toEqual(matches.length)
expect(matches.length).toEqual(results.length)
for (let i = 0; i < results.length; i++) {
const test = results[i]
const match = matches[i]
Expand Down

0 comments on commit 2184d3b

Please sign in to comment.