import { describe, expect, it } from 'vitest';
|
|
import { getScriptFunc } from './common';
|
|
describe('getScriptFunc', () => {
|
it('accepts async button scripts', async () => {
|
const script = getScriptFunc('async ({ value }) => await Promise.resolve(value)');
|
|
expect(typeof script).toBe('function');
|
expect(await script({ value: 'reprint' })).toBe('reprint');
|
});
|
|
it('rejects non-functions and invalid scripts', () => {
|
expect(getScriptFunc('({ value: 1 })')).toBe(false);
|
expect(getScriptFunc('not valid javascript')).toBe(false);
|
});
|
});
|