fix: update test case to use require instead of import

- Change from ES6 import syntax to CommonJS require syntax
- Fix 'System is not defined' error in test environment
- Ensure test runs properly in webpack test framework
This commit is contained in:
Deepak Prajapati 2025-10-06 20:05:47 +05:30
parent dd4769b5ff
commit 20dc109ec2
2 changed files with 9 additions and 5 deletions

View File

@ -1,10 +1,11 @@
import React, { useEffect } from "react";
/* This test verifies that default imports work correctly with SystemJS externals
* when the external module doesn't have a default property (e.g., React)
*/
it("should correctly handle default import from SystemJS external", function() {
const React = require("react");
const { useEffect } = require("react");
// React should be the entire module object, not undefined
expect(React).toBeDefined();
expect(typeof React).toBe("object");

View File

@ -1,6 +1,3 @@
import React, { useEffect } from "react";
import ReactWithDefault, { useEffect as useEffectWithDefault } from "react-with-default";
/* This test verifies that default imports work correctly with SystemJS externals
* in both scenarios:
* 1. External module without default property (traditional SystemJS)
@ -8,6 +5,9 @@ import ReactWithDefault, { useEffect as useEffectWithDefault } from "react-with-
*/
it("should correctly handle default import from SystemJS external without default property", function() {
const React = require("react");
const { useEffect } = require("react");
// React should be the entire module object, not undefined
expect(React).toBeDefined();
expect(typeof React).toBe("object");
@ -22,6 +22,9 @@ it("should correctly handle default import from SystemJS external without defaul
});
it("should correctly handle default import from SystemJS external with default property", function() {
const ReactWithDefault = require("react-with-default");
const { useEffect: useEffectWithDefault } = require("react-with-default");
// ReactWithDefault should be the default property value
expect(ReactWithDefault).toBeDefined();
expect(typeof ReactWithDefault).toBe("object");