silphius/app/swcx/evaluators/array.test.js

18 lines
532 B
JavaScript
Raw Normal View History

2024-06-16 08:01:01 -05:00
import {expect, test} from 'vitest';
import {first} from '@/swcx/builders.js';
import evaluate from '@/swcx/evaluate.js';
test('evaluates array of literals', async () => {
expect(evaluate(await first('[1.5, 2, "three"]')))
.to.deep.include({value: [1.5, 2, 'three']});
});
test('evaluates array containing promises', async () => {
const evaluated = evaluate(await first('[1.5, 2, await "three"]'));
expect(evaluated.async)
.to.equal(true);
expect(await evaluated.value)
.to.deep.equal([1.5, 2, 'three']);
});