File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -90,9 +90,11 @@ waitForApiKey(
90
90
Math.min(retryCount * 200, 5000),
91
91
} : WaitForApiKeyOptions,
92
92
requestOptions?: RequestOptions
93
- ): Promise<ApiError | GetApiKeyResponse > {
93
+ ): Promise<GetApiKeyResponse | undefined > {
94
94
let retryCount = 0;
95
- const baseIteratorOptions: IterableOptions< ApiError | GetApiKeyResponse> = {
95
+ const baseIteratorOptions: IterableOptions<
96
+ GetApiKeyResponse | undefined
97
+ > = {
96
98
aggregator: () => (retryCount += 1),
97
99
error: {
98
100
validate: () => retryCount >= maxRetries,
@@ -135,9 +137,15 @@ waitForApiKey(
135
137
return createIterablePromise({
136
138
...baseIteratorOptions,
137
139
func: () =>
138
- this.getApiKey({ key } , requestOptions).catch((error) => error),
139
- validate: (error: ApiError) =>
140
- operation === 'add' ? error.status !== 404 : error.status === 404,
140
+ this.getApiKey({ key } , requestOptions).catch((error: ApiError) => {
141
+ if (error.status === 404) {
142
+ return undefined;
143
+ }
144
+
145
+ throw error;
146
+ }),
147
+ validate: (response) =>
148
+ operation === 'add' ? response !== undefined : response === undefined,
141
149
});
142
150
},
143
151
Original file line number Diff line number Diff line change @@ -46,7 +46,12 @@ describe('{{testType}}', () => {
46
46
expect(result).toEqual({ {{match.parameters} }});
47
47
{ {/matchIsJSON} }
48
48
{ {^matchIsJSON} }
49
- expect(result).toEqual("{ {{match} }}");
49
+ { {#matchIsNull} }
50
+ expect(result).toBeUndefined();
51
+ { {/matchIsNull} }
52
+ { {^matchIsNull} }
53
+ expect(result).toEqual("{ {{match} }}");
54
+ { {/matchIsNull} }
50
55
{ {/matchIsJSON} }
51
56
{ {/testResponse} }
52
57
{ {/isError} }
You can’t perform that action at this time.
0 commit comments