From 9d6be02c6404cdc44f4ff16801dedf3bc41778e7 Mon Sep 17 00:00:00 2001 From: Jacob M-G Evans <27247160+JacobMGEvans@users.noreply.github.com> Date: Fri, 8 Apr 2022 07:41:23 -0500 Subject: [PATCH] fix: Mocked version of `mockFetchKVGetValue` types were inconsistent with the real function being mocked `fetchKVGetValue` (#769) --- packages/wrangler/src/__tests__/helpers/mock-cfetch.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/wrangler/src/__tests__/helpers/mock-cfetch.ts b/packages/wrangler/src/__tests__/helpers/mock-cfetch.ts index 41520b14c216..111c11fa9772 100644 --- a/packages/wrangler/src/__tests__/helpers/mock-cfetch.ts +++ b/packages/wrangler/src/__tests__/helpers/mock-cfetch.ts @@ -181,6 +181,9 @@ export function unsetAllMocks() { const kvGetMocks = new Map(); +/** + * @mocked typeof fetchKVGetValue + */ export function mockFetchKVGetValue( accountId: string, namespaceId: string, @@ -188,7 +191,8 @@ export function mockFetchKVGetValue( ) { const mapKey = `${accountId}/${namespaceId}/${key}`; if (kvGetMocks.has(mapKey)) { - return kvGetMocks.get(mapKey); + const value = kvGetMocks.get(mapKey); + if (value !== undefined) return Promise.resolve(value); } throw new Error(`no mock value found for \`kv:key get\` - ${mapKey}`); }