(identifier: string)
| 341 | |
| 342 | describe('lookup', () => { |
| 343 | function lookup(identifier: string) { |
| 344 | const result = parse(code, ESModuleParser()); |
| 345 | if (!result.success) { |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | for (const item of result.result as any[]) { |
| 350 | if (item.type === 'const') { |
| 351 | if (item.name === identifier) { |
| 352 | return item; |
| 353 | } |
| 354 | } else if (item.type === 'function') { |
| 355 | if (item.name === identifier) { |
| 356 | return item; |
| 357 | } |
| 358 | } else if (item.type === 'export') { |
| 359 | if (item.exported.name === identifier) { |
| 360 | return item.exported; |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | it('can lookup const', () => { |
| 367 | expect(lookup('a')).toEqual({ |
no test coverage detected