Skip to content

Commit ef0a6ad

Browse files
committed
fix: no fallback x
Signed-off-by: a.chabot <a.chabot@salesforce.com>
1 parent 2d286ad commit ef0a6ad

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/@lwc/jest-transformer/src/__tests__/extract-namespace.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
const { extractNamespace } = require('../extract-namespace');
22

33
describe('extractNamespace', () => {
4-
it("always returns 'x'", () => {
5-
expect(extractNamespace('/repo/src/foo.js')).toBe('x');
4+
it("returns '' when path does not match modules/ or jest-modules/ layout", () => {
5+
expect(extractNamespace('/repo/src/foo.js')).toBe('');
6+
});
7+
8+
it('returns the namespace segment when path is /modules/{namespace}/...', () => {
69
expect(extractNamespace('/modules/x/foo/bar.js')).toBe('x');
710
expect(extractNamespace('/modules/x/foo/bar/baz.js')).toBe('x');
811
});
@@ -37,11 +40,7 @@ describe('extractNamespace', () => {
3740
expect(extractNamespace('packages/pkg/modules/custom/lib/lib.js')).toBe('custom');
3841
});
3942

40-
it("returns 'x' when path does not contain modules/ or jest-modules/", () => {
41-
expect(extractNamespace('/repo/src/foo.js')).toBe('x');
42-
});
43-
44-
it("returns 'x' when modules segment has no trailing segment", () => {
45-
expect(extractNamespace('/repo/modules')).toBe('x');
43+
it("returns '' when modules segment has no trailing path segment", () => {
44+
expect(extractNamespace('/repo/modules')).toBe('');
4645
});
4746
});

packages/@lwc/jest-transformer/src/extract-namespace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* - modules/{namespace}/{component}/{component}.js
1212
* - modules/{namespace}/{component}/__tests__/...
1313
* - jest-modules/{namespace}/{component}/{component}.js
14-
* Returns 'x' as fallback if the namespace cannot be determined
14+
* Returns '' if the namespace cannot be determined
1515
* @param {string} filePath
1616
* @returns {string}
1717
*/

0 commit comments

Comments
 (0)