Skip to content

Commit

Permalink
fix: Mocked version of mockFetchKVGetValue types were inconsistent …
Browse files Browse the repository at this point in the history
…with the real function being mocked `fetchKVGetValue` (#769)
  • Loading branch information
JacobMGEvans authored Apr 8, 2022
1 parent 836ad59 commit 9d6be02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/wrangler/src/__tests__/helpers/mock-cfetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,18 @@ export function unsetAllMocks() {

const kvGetMocks = new Map<string, string>();

/**
* @mocked typeof fetchKVGetValue
*/
export function mockFetchKVGetValue(
accountId: string,
namespaceId: string,
key: string
) {
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}`);
}
Expand Down

0 comments on commit 9d6be02

Please sign in to comment.