Skip to content

Comments

test(utils): add unit tests for isOneLineExpressionExport#539

Open
bashlor wants to merge 3 commits intoNodeSecure:masterfrom
bashlor:test/isOneLineExpressionExport
Open

test(utils): add unit tests for isOneLineExpressionExport#539
bashlor wants to merge 3 commits intoNodeSecure:masterfrom
bashlor:test/isOneLineExpressionExport

Conversation

@bashlor
Copy link
Contributor

@bashlor bashlor commented Feb 18, 2026

Adds unit tests for isOneLineExpressionExport covering:

  • empty and multi-statement bodies
  • direct require calls
  • module.exports assignments
  • conditional and logical expressions
  • member expressions
  • non-require expressions

@changeset-bot
Copy link

changeset-bot bot commented Feb 18, 2026

🦋 Changeset detected

Latest commit: 0466c66

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nodesecure/js-x-ray Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines 8 to 11
// Import Internal Dependencies
import { isOneLineExpressionExport } from "../../src/utils/index.ts";
describe("isOneLineExpressionExport()", () => {
it("should return false for empty body", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Import Internal Dependencies
import { isOneLineExpressionExport } from "../../src/utils/index.ts";
describe("isOneLineExpressionExport()", () => {
it("should return false for empty body", () => {
// Import Internal Dependencies
import { isOneLineExpressionExport } from "../../src/utils/index.ts";
describe("isOneLineExpressionExport()", () => {
it("should return false for empty body", () => {

Comment on lines +16 to +19
const body = parseScript(`
require('a');
require('b');
`).body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const body = parseScript(`
require('a');
require('b');
`).body;
const { body } = parseScript(`
require('a');
require('b');
`);

I’d use destructuring here (and in all tests). What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants