From c657af2eb23be5998e9483f5e5de43bc00d959fd Mon Sep 17 00:00:00 2001 From: Mike Burr <39976424+mburr-salesforce@users.noreply.github.com> Date: Tue, 30 May 2023 17:17:12 -0400 Subject: [PATCH] feat: backport GraphQL stub to summer23 (#316) * feat: add uiGraphQLApi module (#310) * feat: add uiGraphQLApi module * fix format * Update src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js Co-authored-by: Ravi Jayaramappa --------- Co-authored-by: Ravi Jayaramappa * fix: fix initial emit for GraphQL adapters (#315) --------- Co-authored-by: Stephen Carraway <57263085+scarrawaySF@users.noreply.github.com> Co-authored-by: Ravi Jayaramappa --- .../uiGraphQLApi/uiGraphQLApi.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js diff --git a/src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js b/src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js new file mode 100644 index 0000000..bcc03c1 --- /dev/null +++ b/src/lightning-stubs/uiGraphQLApi/uiGraphQLApi.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2023, salesforce.com, inc. + * All rights reserved. + * SPDX-License-Identifier: MIT + * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT + */ +import { createTestWireAdapter } from '@salesforce/wire-service-jest-util'; + +export class graphql extends createTestWireAdapter() { + static emit(value, filterFn) { + super.emit({ data: value, errors: undefined }, filterFn); + } + + static emitErrors(errors, filterFn) { + super.emit({ data: undefined, errors }, filterFn); + } + + constructor(dataCallback) { + super(dataCallback); + + graphql.emit(undefined); + } +} + +export const gql = jest.fn(); +export const refreshGraphQL = jest.fn();