Skip to content

Commit 544f95a

Browse files
authored
fix: apex automock should return a resolved promise (#231)
1 parent 0857e58 commit 544f95a

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

jest.config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2018, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: MIT
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+
*/
7+
'use strict';
8+
9+
const path = require('path');
10+
11+
module.exports = {
12+
moduleFileExtensions: ['js', 'html'],
13+
transform: {
14+
'^.+\\.(js|html|css)$': require.resolve('@lwc/jest-transformer'),
15+
},
16+
resolver: path.resolve(__dirname, './src/resolver.js'),
17+
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
18+
snapshotSerializers: [require.resolve('@lwc/jest-serializer')],
19+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Copyright (c) 2018, salesforce.com, inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: MIT
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6+
*/
7+
import method from '../method';
8+
9+
describe('apex resources', () => {
10+
it('should return a resolved promise when apex method is invoked imperatively', () => {
11+
let resolved = false;
12+
method().then(() => (resolved = true));
13+
14+
return Promise.resolve().then(() => {
15+
expect(resolved).toBe(true);
16+
});
17+
});
18+
});

src/apex-stubs/method/method.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
*/
77
import { createApexTestWireAdapter } from '@salesforce/wire-service-jest-util';
88

9-
export default createApexTestWireAdapter(jest.fn());
9+
export default createApexTestWireAdapter(jest.fn().mockImplementation(() => Promise.resolve()));

0 commit comments

Comments
 (0)