Skip to content

Commit 8da52b2

Browse files
authored
update mock for lightning/graphql (#470)
1 parent 5d76e68 commit 8da52b2

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/lightning-stubs/graphql/graphql.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,34 @@
44
* SPDX-License-Identifier: MIT
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
66
*/
7-
import { gql, graphql } from '../uiGraphQLApi/uiGraphQLApi';
7+
import { createTestWireAdapter } from '@salesforce/wire-service-jest-util';
8+
export class graphql extends createTestWireAdapter() {
9+
static emit(value, filterFn, refreshFn) {
10+
super.emit(
11+
{
12+
data: value,
13+
errors: undefined,
14+
...(refreshFn !== undefined && { refresh: refreshFn }),
15+
},
16+
filterFn,
17+
);
18+
}
819

9-
export { gql, graphql };
20+
static emitErrors(errors, filterFn, refreshFn) {
21+
super.emit(
22+
{
23+
data: undefined,
24+
errors,
25+
...(refreshFn !== undefined && { refresh: refreshFn }),
26+
},
27+
filterFn,
28+
);
29+
}
30+
31+
constructor(dataCallback) {
32+
super(dataCallback);
33+
34+
graphql.emit(undefined);
35+
}
36+
}
37+
export const gql = jest.fn();

0 commit comments

Comments
 (0)