1
+ /* eslint-disable max-nested-callbacks */
1
2
// Import Node.js Dependencies
2
3
import { describe , it } from "node:test" ;
3
4
import assert from "node:assert" ;
4
5
import { readFileSync } from "node:fs" ;
5
6
6
7
// Import Internal Dependencies
7
- import { AstAnalyser } from "../src/AstAnalyser.js" ;
8
- import { JsSourceParser } from "../src/JsSourceParser.js" ;
8
+ import { AstAnalyser , JsSourceParser } from "../index.js" ;
9
9
import { SourceFile } from "../src/SourceFile.js" ;
10
10
import {
11
11
customProbes ,
@@ -255,7 +255,7 @@ describe("AstAnalyser", (t) => {
255
255
} ) ;
256
256
257
257
describe ( "analyseFile" , ( ) => {
258
- it ( "remove the packageName from the dependencies list" , async ( ) => {
258
+ it ( "remove the packageName from the dependencies list" , async ( ) => {
259
259
const result = await getAnalyser ( ) . analyseFile (
260
260
new URL ( "depName.js" , FIXTURE_URL ) ,
261
261
{ module : false , packageName : "foobar" }
@@ -268,7 +268,7 @@ describe("AstAnalyser", (t) => {
268
268
) ;
269
269
} ) ;
270
270
271
- it ( "should fail with a parsing error" , async ( ) => {
271
+ it ( "should fail with a parsing error" , async ( ) => {
272
272
const result = await getAnalyser ( ) . analyseFile (
273
273
new URL ( "parsingError.js" , FIXTURE_URL ) ,
274
274
{ module : false , packageName : "foobar" }
@@ -286,18 +286,18 @@ describe("AstAnalyser", (t) => {
286
286
const url = new URL ( "depName.js" , FIXTURE_URL ) ;
287
287
288
288
describe ( "initialize" , ( ) => {
289
- it ( "should throw if initialize is not a function" , async ( ) => {
289
+ it ( "should throw if initialize is not a function" , async ( ) => {
290
290
const res = await analyser . analyseFile (
291
291
url , {
292
- initialize : "foo"
293
- } ) ;
292
+ initialize : "foo"
293
+ } ) ;
294
294
295
295
assert . strictEqual ( res . ok , false ) ;
296
296
assert . strictEqual ( res . warnings [ 0 ] . value , "options.initialize must be a function" ) ;
297
297
assert . strictEqual ( res . warnings [ 0 ] . kind , "parsing-error" ) ;
298
298
} ) ;
299
299
300
- it ( "should call the initialize function" , async ( t ) => {
300
+ it ( "should call the initialize function" , async ( t ) => {
301
301
const initialize = t . mock . fn ( ) ;
302
302
303
303
await analyser . analyseFile ( url , {
@@ -307,7 +307,7 @@ describe("AstAnalyser", (t) => {
307
307
assert . strictEqual ( initialize . mock . callCount ( ) , 1 ) ;
308
308
} ) ;
309
309
310
- it ( "should pass the source file as first argument" , async ( t ) => {
310
+ it ( "should pass the source file as first argument" , async ( t ) => {
311
311
const initialize = t . mock . fn ( ) ;
312
312
313
313
await analyser . analyseFile ( url , {
@@ -319,18 +319,18 @@ describe("AstAnalyser", (t) => {
319
319
} ) ;
320
320
321
321
describe ( "finalize" , ( ) => {
322
- it ( "should throw if finalize is not a function" , async ( ) => {
322
+ it ( "should throw if finalize is not a function" , async ( ) => {
323
323
const res = await analyser . analyseFile (
324
324
url , {
325
- finalize : "foo"
326
- } ) ;
325
+ finalize : "foo"
326
+ } ) ;
327
327
328
328
assert . strictEqual ( res . ok , false ) ;
329
329
assert . strictEqual ( res . warnings [ 0 ] . value , "options.finalize must be a function" ) ;
330
330
assert . strictEqual ( res . warnings [ 0 ] . kind , "parsing-error" ) ;
331
331
} ) ;
332
332
333
- it ( "should call the finalize function" , async ( t ) => {
333
+ it ( "should call the finalize function" , async ( t ) => {
334
334
const finalize = t . mock . fn ( ) ;
335
335
336
336
await analyser . analyseFile ( url , {
@@ -340,7 +340,7 @@ describe("AstAnalyser", (t) => {
340
340
assert . strictEqual ( finalize . mock . callCount ( ) , 1 ) ;
341
341
} ) ;
342
342
343
- it ( "should pass the source file as first argument" , async ( t ) => {
343
+ it ( "should pass the source file as first argument" , async ( t ) => {
344
344
const finalize = t . mock . fn ( ) ;
345
345
346
346
await analyser . analyseFile ( url , {
@@ -352,7 +352,7 @@ describe("AstAnalyser", (t) => {
352
352
} ) ;
353
353
354
354
355
- it ( "intialize should be called before finalize" , async ( ) => {
355
+ it ( "intialize should be called before finalize" , async ( ) => {
356
356
const calls = [ ] ;
357
357
358
358
await analyser . analyseFile ( url , {
@@ -411,8 +411,8 @@ describe("AstAnalyser", (t) => {
411
411
it ( "should remove multiple HTML comments" , ( ) => {
412
412
const preparedSource = getAnalyser ( ) . prepareSource (
413
413
"<!-- const yo = 5; -->\nconst yo = 'foo'\n<!-- const yo = 5; -->" , {
414
- removeHTMLComments : true
415
- } ) ;
414
+ removeHTMLComments : true
415
+ } ) ;
416
416
417
417
assert . strictEqual ( preparedSource , "\nconst yo = 'foo'\n" ) ;
418
418
} ) ;
0 commit comments