Skip to content

Commit

Permalink
revert(apex-methods-automock): reverts functionality providing apex a…
Browse files Browse the repository at this point in the history
…utomocks (#234)

fixes #232

This PR reverts #231, #210, and #208. They provided functionality to auto mock apex methods.

**Note:** Test authors will need to keep implementing their own apex (+apexContinuation) methods mocks after this PR is merged.

* Revert "fix: apex automock should return a resolved promise (#231)"

This reverts commit 544f95a.

* Revert "fix: add apex stubs to the transformIgnorePatterns (#210)"

This reverts commit fe8381a.

* Revert "fix: automock apex methods with valid wire adapters (#208)"

This reverts commit 125c689.
  • Loading branch information
jodarove authored Jun 30, 2021
1 parent 544f95a commit f8586d5
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 67 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"overrides": [
{
"files": ["src/lightning-stubs/**", "src/apex-stubs/**"],
"files": ["src/lightning-stubs/**"],
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
Expand Down
19 changes: 0 additions & 19 deletions jest.config.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/apex-stubs/method/__tests__/apex-method.test.js

This file was deleted.

9 changes: 0 additions & 9 deletions src/apex-stubs/method/method.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const jestConfig = {
'^.+\\.(js|html|css)$': require.resolve('@lwc/jest-transformer'),
},
transformIgnorePatterns: [
'/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/(lightning|apex)-stubs)/)',
'/node_modules/(?!(.*@salesforce/sfdx-lwc-jest/src/lightning-stubs)/)',
],
setupFilesAfterEnv: jestPreset.setupFilesAfterEnv || [],
resolver: path.resolve(__dirname, './resolver.js'),
Expand Down
22 changes: 3 additions & 19 deletions src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,20 @@ function resolveAsFile(name, extensions) {
return undefined;
}

function getModuleMock(modulePath, moduleName) {
const p = path.join(__dirname, modulePath, moduleName);
function getLightningMock(modulePath) {
const p = path.join(__dirname, 'lightning-stubs', modulePath);
if (fs.existsSync(p)) {
return path.join(p, moduleName + '.js');
return path.join(p, modulePath + '.js');
}
}

function getLightningMock(moduleName) {
return getModuleMock('lightning-stubs', moduleName);
}

function getApexMock(moduleName) {
return getModuleMock('apex-stubs', moduleName);
}

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

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

// See https://developer.salesforce.com/docs/component-library/documentation/en/lwc/reference_salesforce_modules
if (
modulePath.startsWith('@salesforce/apex/') ||
modulePath.startsWith('@salesforce/apexContinuation/')
) {
return getApexMock('method');
}

if (ns === DEFAULT_NAMESPACE) {
const paths = getModulePaths();
for (let i = 0; i < paths.length; i++) {
Expand Down

0 comments on commit f8586d5

Please sign in to comment.