File tree Expand file tree Collapse file tree
packages/@lwc/jest-transformer/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11const { extractNamespace } = require ( '../extract-namespace' ) ;
22
33describe ( '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} ) ;
Original file line number Diff line number Diff line change 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 */
You can’t perform that action at this time.
0 commit comments