Skip to content

Improve macros.js test coverage and fixed module export in macros.js#5784

Merged
omsuneri merged 2 commits intosugarlabs:masterfrom
stutijain2006:MacrosTest
Feb 19, 2026
Merged

Improve macros.js test coverage and fixed module export in macros.js#5784
omsuneri merged 2 commits intosugarlabs:masterfrom
stutijain2006:MacrosTest

Conversation

@stutijain2006
Copy link
Contributor

This PR improves the test case coverages of macros.js and fixes an issue with how functions were being imported.

Test Cases Added-

  1. Edge Test case for blockIsMacro to test the behavior when a block exists in protoBlockDict but has no macroFunc and when a custom block has macroFunc even if it is not part of the built-in list.
  2. Override behavior Test for getMicroExpansion which verifies that a protoBlock with macroFunc correctly overrides built-in macro definities.
  3. Coordinate propagation Test to verify that built-in macros correctly use the provided x and y coordinates in their expansion.

Module Export Issue-
Previously macros.js exported functions like this:

module.exports = blockIsMacro;
module.exports = getMacroExpansion;

the second line overwrites the first export, making only getMacroExpansion accessible.

Now, both functions are exported properly:
module.exports = { blockIsMacro, getMacroExpansion };
and the import in tests was updated to
const { blockIsMacro, getMacroExpansion } = require("../macros");

After these additions-

  1. 100% statement coverage
  2. 100% function coverage
  3. 93.75% branch coverage
  4. All tests passing
    This ensures macros.js is now fully tested and more robust against edge cases.
image image

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@vanshika2720
Copy link
Contributor

vanshika2720 commented Feb 18, 2026

@stutijain2006 please pull the latest master, rebase it into your branch, and push again.

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

@omsuneri omsuneri merged commit 8e3fbee into sugarlabs:master Feb 19, 2026
7 checks passed
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