Skip to content

Commit 7f7053c

Browse files
committed
fix
1 parent 2ebf217 commit 7f7053c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

tests/test_languages/test_js_code_replacer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,12 @@ def test_convert_destructured_require(self):
167167
f"CJS to ESM conversion failed.\nInput: {code}\nExpected: {expected}\nGot: {result}"
168168
)
169169

170-
def test_convert_relative_require_adds_extension(self):
171-
"""Test that relative imports get .js extension added - exact output."""
170+
def test_convert_relative_require_preserves_path(self):
171+
"""Test that relative imports preserve the original path without adding extension."""
172172
code = "const { helper } = require('./utils');"
173173
result = convert_commonjs_to_esm(code)
174174

175-
expected = "import { helper } from './utils.js';"
175+
expected = "import { helper } from './utils';"
176176
assert result.strip() == expected, (
177177
f"CJS to ESM conversion failed.\nInput: {code}\nExpected: {expected}\nGot: {result}"
178178
)
@@ -182,7 +182,7 @@ def test_convert_property_access_require(self):
182182
code = "const myHelper = require('./utils').helperFunction;"
183183
result = convert_commonjs_to_esm(code)
184184

185-
expected = "import { helperFunction as myHelper } from './utils.js';"
185+
expected = "import { helperFunction as myHelper } from './utils';"
186186
assert result.strip() == expected, (
187187
f"CJS to ESM conversion failed.\nInput: {code}\nExpected: {expected}\nGot: {result}"
188188
)
@@ -192,7 +192,7 @@ def test_convert_default_property_access(self):
192192
code = "const MyClass = require('./class').default;"
193193
result = convert_commonjs_to_esm(code)
194194

195-
expected = "import MyClass from './class.js';"
195+
expected = "import MyClass from './class';"
196196
assert result.strip() == expected, (
197197
f"CJS to ESM conversion failed.\nInput: {code}\nExpected: {expected}\nGot: {result}"
198198
)
@@ -207,7 +207,7 @@ def test_convert_multiple_requires(self):
207207
result = convert_commonjs_to_esm(code)
208208

209209
expected = """\
210-
import { add, subtract } from './math.js';
210+
import { add, subtract } from './math';
211211
import lodash from 'lodash';
212212
import path from 'path';"""
213213

@@ -316,7 +316,7 @@ def test_convert_mixed_code_to_esm(self):
316316
result = ensure_module_system_compatibility(code, ModuleSystem.ES_MODULE)
317317

318318
# Should convert require to import
319-
assert "import { helper } from './helpers.js';" in result
319+
assert "import { helper } from './helpers';" in result
320320
assert "require" not in result, f"require should be converted to import. Got:\n{result}"
321321

322322
def test_convert_mixed_code_to_commonjs(self):

0 commit comments

Comments
 (0)