From 9a8458044a40aef9fe7a9c5be78fe285ed3e7e48 Mon Sep 17 00:00:00 2001
From: Michelle Chu <michelle.chu@zapier.com>
Date: Thu, 28 Mar 2019 16:42:15 -0500
Subject: [PATCH 1/3] Add optional parameter to createAppTester to customize
 storeKey and update index.d.ts

---
 index.d.ts                     | 3 ++-
 src/tools/create-app-tester.js | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/index.d.ts b/index.d.ts
index f15b88b..89d086a 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -12,7 +12,8 @@ export const tools: { env: { inject: (filename?: string) => void } };
 
 // see: https://github.com/zapier/zapier-platform-cli/issues/339#issue-336888249
 export const createAppTester: (
-  appRaw: object
+  appRaw: object,
+  storeKey: string
 ) => <T extends any, B extends Bundle>(
   func: (z: ZObject, bundle: B) => Promise<T>,
   bundle?: Partial<B> // partial so we don't have to make a full bundle in tests
diff --git a/src/tools/create-app-tester.js b/src/tools/create-app-tester.js
index 7d48f08..98b17c6 100644
--- a/src/tools/create-app-tester.js
+++ b/src/tools/create-app-tester.js
@@ -36,7 +36,7 @@ const promisifyHandler = handler => {
 };
 
 // A shorthand compatible wrapper for testing.
-const createAppTester = appRaw => {
+const createAppTester = (appRaw, storeKey = null) => {
   const handler = createLambdaHandler(appRaw);
   const createHandlerPromise = promisifyHandler(handler);
 
@@ -46,6 +46,7 @@ const createAppTester = appRaw => {
     bundle = bundle || {};
 
     const method = resolveMethodPath(appRaw, methodOrFunc);
+    let myStoreKey = storeKey ? `testKey-${storeKey}` : `testKey-${method}-${randomSeed}`
 
     const event = {
       command: 'execute',
@@ -53,7 +54,7 @@ const createAppTester = appRaw => {
       bundle,
       storeKey: shouldPaginate(appRaw, method)
         ? // this key will be consistent across runs but unique to each test so we don't lose cursors
-          `testKey-${method}-${randomSeed}`
+          myStoreKey
         : null
     };
 

From ceb56fd8a51a306278ce0f684a78e62802783f65 Mon Sep 17 00:00:00 2001
From: Michelle Chu <michelle.chu@zapier.com>
Date: Thu, 28 Mar 2019 21:51:03 -0500
Subject: [PATCH 2/3] Update variable name

---
 index.d.ts                     |  2 +-
 src/tools/create-app-tester.js | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/index.d.ts b/index.d.ts
index 89d086a..9642f17 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -13,7 +13,7 @@ export const tools: { env: { inject: (filename?: string) => void } };
 // see: https://github.com/zapier/zapier-platform-cli/issues/339#issue-336888249
 export const createAppTester: (
   appRaw: object,
-  storeKey: string
+  customStoreKey?: string
 ) => <T extends any, B extends Bundle>(
   func: (z: ZObject, bundle: B) => Promise<T>,
   bundle?: Partial<B> // partial so we don't have to make a full bundle in tests
diff --git a/src/tools/create-app-tester.js b/src/tools/create-app-tester.js
index 98b17c6..3bdbaa9 100644
--- a/src/tools/create-app-tester.js
+++ b/src/tools/create-app-tester.js
@@ -36,7 +36,7 @@ const promisifyHandler = handler => {
 };
 
 // A shorthand compatible wrapper for testing.
-const createAppTester = (appRaw, storeKey = null) => {
+const createAppTester = (appRaw, customStoreKey) => {
   const handler = createLambdaHandler(appRaw);
   const createHandlerPromise = promisifyHandler(handler);
 
@@ -46,16 +46,17 @@ const createAppTester = (appRaw, storeKey = null) => {
     bundle = bundle || {};
 
     const method = resolveMethodPath(appRaw, methodOrFunc);
-    let myStoreKey = storeKey ? `testKey-${storeKey}` : `testKey-${method}-${randomSeed}`
+    customStoreKey = shouldPaginate(appRaw, method)
+    ? customStoreKey
+      ? `testKey-${customStoreKey}`
+      : `testKey-${method}-${randomSeed}`
+    : undefined;
 
     const event = {
       command: 'execute',
       method,
       bundle,
-      storeKey: shouldPaginate(appRaw, method)
-        ? // this key will be consistent across runs but unique to each test so we don't lose cursors
-          myStoreKey
-        : null
+      customStoreKey,
     };
 
     if (process.env.LOG_TO_STDOUT) {

From f9de80141fd9a56c8046234cc3ac32ff3a887ece Mon Sep 17 00:00:00 2001
From: Michelle Chu <michelle.chu@zapier.com>
Date: Mon, 1 Apr 2019 09:39:15 -0500
Subject: [PATCH 3/3] Update undefined to null

---
 src/tools/create-app-tester.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/create-app-tester.js b/src/tools/create-app-tester.js
index 3bdbaa9..df2a34b 100644
--- a/src/tools/create-app-tester.js
+++ b/src/tools/create-app-tester.js
@@ -50,7 +50,7 @@ const createAppTester = (appRaw, customStoreKey) => {
     ? customStoreKey
       ? `testKey-${customStoreKey}`
       : `testKey-${method}-${randomSeed}`
-    : undefined;
+    : null;
 
     const event = {
       command: 'execute',