Skip to content

Commit

Permalink
remove custom namespace logic in resolver (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor authored Mar 1, 2019
1 parent 20a5044 commit cd38feb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const lwcResolver = require('@lwc/jest-resolver');
const {
PROJECT_ROOT,
getModulePaths,
getNamespace,
DEFAULT_NAMESPACE,
} = require('./utils/project.js');

const {
Expand Down Expand Up @@ -60,13 +60,12 @@ function getLightningMock(modulePath) {

function getModule(modulePath, options) {
const { ns, name } = getInfoFromId(modulePath);
const projectNs = getNamespace();

if (ns === 'lightning') {
return getLightningMock(name);
}

if (projectNs === ns) {
if (ns === DEFAULT_NAMESPACE) {
const paths = getModulePaths();
for (let i = 0; i < paths.length; i++) {
const file = resolveAsFile(path.join(PROJECT_ROOT, paths[i], name, name), options.extensions);
Expand Down
1 change: 0 additions & 1 deletion src/utils/__mocks__/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ module.exports = {
getSfdxProjectJson: () => {
return { mock: true, sourceApiVersion: expectedApiVersion }
},
getNamespace: 'mockedNamespace',
getModulePaths: () => ['C:/WIN32/SYSTEM']
};
6 changes: 1 addition & 5 deletions src/utils/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,9 @@ function getModulePaths() {
return paths;
}

function getNamespace() {
return getSfdxProjectJson().namespace || DEFAULT_NAMESPACE;
}

module.exports = {
PROJECT_ROOT,
getSfdxProjectJson,
getNamespace,
DEFAULT_NAMESPACE,
getModulePaths,
};

0 comments on commit cd38feb

Please sign in to comment.