Skip to content

Commit 777ed54

Browse files
committed
refactor(test): import from project entry file to avoid issues
1 parent 69272f6 commit 777ed54

File tree

6 files changed

+22
-26
lines changed

6 files changed

+22
-26
lines changed

test/AstAnalyser.spec.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
/* eslint-disable max-nested-callbacks */
12
// Import Node.js Dependencies
23
import { describe, it } from "node:test";
34
import assert from "node:assert";
45
import { readFileSync } from "node:fs";
56

67
// Import Internal Dependencies
7-
import { AstAnalyser } from "../src/AstAnalyser.js";
8-
import { JsSourceParser } from "../src/JsSourceParser.js";
8+
import { AstAnalyser, JsSourceParser } from "../index.js";
99
import { SourceFile } from "../src/SourceFile.js";
1010
import {
1111
customProbes,
@@ -255,7 +255,7 @@ describe("AstAnalyser", (t) => {
255255
});
256256

257257
describe("analyseFile", () => {
258-
it("remove the packageName from the dependencies list", async () => {
258+
it("remove the packageName from the dependencies list", async() => {
259259
const result = await getAnalyser().analyseFile(
260260
new URL("depName.js", FIXTURE_URL),
261261
{ module: false, packageName: "foobar" }
@@ -268,7 +268,7 @@ describe("AstAnalyser", (t) => {
268268
);
269269
});
270270

271-
it("should fail with a parsing error", async () => {
271+
it("should fail with a parsing error", async() => {
272272
const result = await getAnalyser().analyseFile(
273273
new URL("parsingError.js", FIXTURE_URL),
274274
{ module: false, packageName: "foobar" }
@@ -286,18 +286,18 @@ describe("AstAnalyser", (t) => {
286286
const url = new URL("depName.js", FIXTURE_URL);
287287

288288
describe("initialize", () => {
289-
it("should throw if initialize is not a function", async () => {
289+
it("should throw if initialize is not a function", async() => {
290290
const res = await analyser.analyseFile(
291291
url, {
292-
initialize: "foo"
293-
});
292+
initialize: "foo"
293+
});
294294

295295
assert.strictEqual(res.ok, false);
296296
assert.strictEqual(res.warnings[0].value, "options.initialize must be a function");
297297
assert.strictEqual(res.warnings[0].kind, "parsing-error");
298298
});
299299

300-
it("should call the initialize function", async (t) => {
300+
it("should call the initialize function", async(t) => {
301301
const initialize = t.mock.fn();
302302

303303
await analyser.analyseFile(url, {
@@ -307,7 +307,7 @@ describe("AstAnalyser", (t) => {
307307
assert.strictEqual(initialize.mock.callCount(), 1);
308308
});
309309

310-
it("should pass the source file as first argument", async (t) => {
310+
it("should pass the source file as first argument", async(t) => {
311311
const initialize = t.mock.fn();
312312

313313
await analyser.analyseFile(url, {
@@ -319,18 +319,18 @@ describe("AstAnalyser", (t) => {
319319
});
320320

321321
describe("finalize", () => {
322-
it("should throw if finalize is not a function", async () => {
322+
it("should throw if finalize is not a function", async() => {
323323
const res = await analyser.analyseFile(
324324
url, {
325-
finalize: "foo"
326-
});
325+
finalize: "foo"
326+
});
327327

328328
assert.strictEqual(res.ok, false);
329329
assert.strictEqual(res.warnings[0].value, "options.finalize must be a function");
330330
assert.strictEqual(res.warnings[0].kind, "parsing-error");
331331
});
332332

333-
it("should call the finalize function", async (t) => {
333+
it("should call the finalize function", async(t) => {
334334
const finalize = t.mock.fn();
335335

336336
await analyser.analyseFile(url, {
@@ -340,7 +340,7 @@ describe("AstAnalyser", (t) => {
340340
assert.strictEqual(finalize.mock.callCount(), 1);
341341
});
342342

343-
it("should pass the source file as first argument", async (t) => {
343+
it("should pass the source file as first argument", async(t) => {
344344
const finalize = t.mock.fn();
345345

346346
await analyser.analyseFile(url, {
@@ -352,7 +352,7 @@ describe("AstAnalyser", (t) => {
352352
});
353353

354354

355-
it("intialize should be called before finalize", async () => {
355+
it("intialize should be called before finalize", async() => {
356356
const calls = [];
357357

358358
await analyser.analyseFile(url, {
@@ -411,8 +411,8 @@ describe("AstAnalyser", (t) => {
411411
it("should remove multiple HTML comments", () => {
412412
const preparedSource = getAnalyser().prepareSource(
413413
"<!-- const yo = 5; -->\nconst yo = 'foo'\n<!-- const yo = 5; -->", {
414-
removeHTMLComments: true
415-
});
414+
removeHTMLComments: true
415+
});
416416

417417
assert.strictEqual(preparedSource, "\nconst yo = 'foo'\n");
418418
});

test/Deobfuscator.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { walk } from "estree-walker";
77

88
// Import Internal Dependencies
99
import { Deobfuscator } from "../src/Deobfuscator.js";
10-
import { JsSourceParser } from "../src/JsSourceParser.js";
10+
import { JsSourceParser } from "../index.js";
1111

1212
describe("Deobfuscator", () => {
1313
describe("identifiers and counters", () => {

test/JsSourceParser.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { describe, it } from "node:test";
33

44
// Import Internal Dependencies
5-
import { JsSourceParser } from "../src/JsSourceParser.js";
5+
import { JsSourceParser } from "../index.js";
66

77
describe("JsSourceParser", () => {
88
describe("parse", () => {

test/NodeCounter.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { walk } from "estree-walker";
77

88
// Import Internal Dependencies
99
import { NodeCounter } from "../src/NodeCounter.js";
10-
import { JsSourceParser } from "../src/JsSourceParser.js";
1110
import { isNode } from "../src/utils/index.js";
11+
import { JsSourceParser } from "../index.js";
1212

1313
describe("NodeCounter", () => {
1414
describe("constructor", () => {

test/runASTAnalysis.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { it } from "node:test";
33
import assert from "node:assert";
44

55
// Import Internal Dependencies
6-
import { runASTAnalysis } from "../index.js";
7-
import { AstAnalyser } from "../src/AstAnalyser.js";
8-
import { JsSourceParser } from "../src/JsSourceParser.js";
6+
import { runASTAnalysis, AstAnalyser, JsSourceParser } from "../index.js";
97
import { FakeSourceParser } from "./fixtures/FakeSourceParser.js";
108
import {
119
customProbes,

test/runASTAnalysisOnFile.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import { it } from "node:test";
33
import assert from "node:assert";
44

55
// Import Internal Dependencies
6-
import { runASTAnalysisOnFile } from "../index.js";
7-
import { AstAnalyser } from "../src/AstAnalyser.js";
6+
import { runASTAnalysisOnFile, AstAnalyser, JsSourceParser } from "../index.js";
87
import { FakeSourceParser } from "./fixtures/FakeSourceParser.js";
9-
import { JsSourceParser } from "../src/JsSourceParser.js";
108
import { customProbes, kWarningUnsafeDanger, kWarningUnsafeImport, kWarningUnsafeStmt } from "./utils/index.js";
119

1210
// CONSTANTS

0 commit comments

Comments
 (0)