Files
vercel__workflow/packages/world-testing/src/addition.mts

34 lines
965 B
TypeScript

import { expect, test, vi } from 'vitest';
import { hydrateWorkflowReturnValue } from '@workflow/core/serialization';
import { createFetcher, startServer } from './util.mjs';
export function addition(world: string) {
test('runs an addition', { timeout: 30_000 }, async () => {
const server = await startServer({ world }).then(createFetcher);
const result = await server.invoke(
'workflows/addition.ts',
'addition',
[1, 2]
);
expect(result.runId).toMatch(/^wrun_.+/);
const run = await vi.waitFor(
async () => {
const run = await server.getRun(result.runId);
expect(run.status).toBe('completed');
expect(run.output).toBeInstanceOf(Uint8Array);
return run;
},
{
interval: 200,
timeout: 25_000,
}
);
const output = await hydrateWorkflowReturnValue(
run.output!,
run.runId,
undefined
);
expect(output).toEqual(3);
});
}