-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isOneLineRequire): must return true for a one line require with n…
…o export (#284)
- Loading branch information
Showing
2 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Import Node.js Dependencies | ||
import { test } from "node:test"; | ||
import assert from "node:assert"; | ||
|
||
// Import Internal Dependencies | ||
import { runASTAnalysis } from "../../index.js"; | ||
|
||
// Regression test for https://github.com/NodeSecure/js-x-ray/issues/283 | ||
test("Given a one line require (with no module.exports) then isOneLineRequire must equal true", () => { | ||
const { isOneLineRequire } = runASTAnalysis(`require('foo.js');`); | ||
|
||
assert.ok(isOneLineRequire); | ||
}); | ||
|
||
test("Given an empty code then isOneLineRequire must equal false", () => { | ||
const { isOneLineRequire } = runASTAnalysis(``); | ||
|
||
assert.strictEqual(isOneLineRequire, false); | ||
}); |