Skip to content

Commit f0c73d8

Browse files
authored
fix: call/callTask accept waitSecs instead of waitForFinish (#176)
1 parent c5ba3cc commit f0c73d8

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/apify/src/actor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { ENV_VARS, INTEGER_ENV_VARS } from '@apify/consts';
55
import { addTimeoutToPromise } from '@apify/timeout';
66
import log, { LogLevel } from '@apify/log';
77
import type {
8-
ActorStartOptions,
8+
ActorCallOptions,
99
ApifyClientOptions,
1010
RunAbortOptions,
11-
TaskStartOptions,
11+
TaskCallOptions,
1212
Webhook,
1313
WebhookEventType,
1414
} from 'apify-client';
@@ -1529,14 +1529,14 @@ export interface ApifyEnv {
15291529

15301530
export type UserFunc<T = unknown> = () => Awaitable<T>;
15311531

1532-
export interface CallOptions extends ActorStartOptions {
1532+
export interface CallOptions extends ActorCallOptions {
15331533
/**
15341534
* User API token that is used to run the actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
15351535
*/
15361536
token?: string;
15371537
}
15381538

1539-
export interface CallTaskOptions extends TaskStartOptions {
1539+
export interface CallTaskOptions extends TaskCallOptions {
15401540
/**
15411541
* User API token that is used to run the actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
15421542
*/

test/apify/actor.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,31 +242,31 @@ describe('Actor', () => {
242242
});
243243

244244
test('works as expected with unfinished run', async () => {
245-
const waitForFinish = 1;
245+
const waitSecs = 1;
246246

247247
const callMock = jest.fn();
248248
callMock.mockResolvedValueOnce(runningRun);
249249
const actorSpy = jest.spyOn(ApifyClient.prototype, 'actor');
250250
actorSpy.mockReturnValueOnce({ call: callMock } as any);
251251
const keyValueStoreSpy = jest.spyOn(ApifyClient.prototype, 'keyValueStore');
252252

253-
const callOutput = await new Actor().call(actId, undefined, { waitForFinish });
253+
const callOutput = await new Actor().call(actId, undefined, { waitSecs });
254254

255255
expect(callOutput).toEqual(runningRun);
256256
expect(actorSpy).toBeCalledWith('some-act-id');
257257
expect(keyValueStoreSpy).not.toBeCalled();
258258
});
259259

260260
test('returns immediately with zero ', async () => {
261-
const waitForFinish = 0;
261+
const waitSecs = 0;
262262

263263
const callMock = jest.fn();
264264
callMock.mockResolvedValueOnce(readyRun);
265265
const actorSpy = jest.spyOn(ApifyClient.prototype, 'actor');
266266
actorSpy.mockReturnValueOnce({ call: callMock } as any);
267267
const keyValueStoreSpy = jest.spyOn(ApifyClient.prototype, 'keyValueStore');
268268

269-
const callOutput = await new Actor().call(actId, undefined, { waitForFinish });
269+
const callOutput = await new Actor().call(actId, undefined, { waitSecs });
270270

271271
expect(callOutput).toEqual(readyRun);
272272
expect(actorSpy).toBeCalledWith('some-act-id');
@@ -368,31 +368,31 @@ describe('Actor', () => {
368368
});
369369

370370
test('works as expected with unfinished run', async () => {
371-
const waitForFinish = 1;
371+
const waitSecs = 1;
372372

373373
const callMock = jest.fn();
374374
callMock.mockResolvedValueOnce(runningRun);
375375
const taskSpy = jest.spyOn(ApifyClient.prototype, 'task');
376376
taskSpy.mockReturnValueOnce({ call: callMock } as any);
377377
const keyValueStoreSpy = jest.spyOn(ApifyClient.prototype, 'keyValueStore');
378378

379-
const callOutput = await new Actor().callTask(taskId, undefined, { waitForFinish });
379+
const callOutput = await new Actor().callTask(taskId, undefined, { waitSecs });
380380

381381
expect(callOutput).toEqual(runningRun);
382382
expect(keyValueStoreSpy).not.toBeCalled();
383383
expect(taskSpy).toBeCalledWith('some-task-id');
384384
});
385385

386386
test('returns immediately with zero ', async () => {
387-
const waitForFinish = 0;
387+
const waitSecs = 0;
388388

389389
const callMock = jest.fn();
390390
callMock.mockResolvedValueOnce(readyRun);
391391
const taskSpy = jest.spyOn(ApifyClient.prototype, 'task');
392392
taskSpy.mockReturnValueOnce({ call: callMock } as any);
393393
const keyValueStoreSpy = jest.spyOn(ApifyClient.prototype, 'keyValueStore');
394394

395-
const callOutput = await new Actor().callTask(taskId, undefined, { waitForFinish });
395+
const callOutput = await new Actor().callTask(taskId, undefined, { waitSecs });
396396

397397
expect(callOutput).toEqual(readyRun);
398398
expect(keyValueStoreSpy).not.toBeCalled();

0 commit comments

Comments
 (0)