|
| 1 | +import test from 'ava'; |
| 2 | +import { v4 as uuid4 } from 'uuid'; |
| 3 | +import { Client } from '@temporalio/client'; |
| 4 | +import { RUN_INTEGRATION_TESTS, Worker } from './helpers'; |
| 5 | +import { defaultOptions } from './mock-native-worker'; |
| 6 | +import { textEncoderDecoder, textEncoderDecoderFromImport } from './workflows'; |
| 7 | + |
| 8 | +if (RUN_INTEGRATION_TESTS) { |
| 9 | + test('Worker runtime exposes TextEncoder and TextDecoder as globals', async (t) => { |
| 10 | + const worker = await Worker.create({ ...defaultOptions, taskQueue: 'test-worker-exposes-textencoderdecoder' }); |
| 11 | + const client = new Client(); |
| 12 | + const result = await worker.runUntil( |
| 13 | + client.workflow.execute(textEncoderDecoder, { |
| 14 | + args: ['a string that will be encoded and decoded'], |
| 15 | + taskQueue: 'test-worker-exposes-textencoderdecoder', |
| 16 | + workflowId: uuid4(), |
| 17 | + workflowExecutionTimeout: '5s', |
| 18 | + }) |
| 19 | + ); |
| 20 | + t.is(result, 'a string that will be encoded and decoded'); |
| 21 | + }); |
| 22 | + |
| 23 | + test('Worker runtime exposes TextEncoder and TextDecoder as overrided import of util', async (t) => { |
| 24 | + const worker = await Worker.create({ ...defaultOptions, taskQueue: 'test-worker-exposes-textencoderdecoder' }); |
| 25 | + const client = new Client(); |
| 26 | + const result = await worker.runUntil( |
| 27 | + client.workflow.execute(textEncoderDecoderFromImport, { |
| 28 | + args: ['a string that will be encoded and decoded'], |
| 29 | + taskQueue: 'test-worker-exposes-textencoderdecoder', |
| 30 | + workflowId: uuid4(), |
| 31 | + workflowExecutionTimeout: '5s', |
| 32 | + }) |
| 33 | + ); |
| 34 | + t.is(result, 'a string that will be encoded and decoded'); |
| 35 | + }); |
| 36 | +} |
0 commit comments