silphius/app/astride/evaluators/await.test.js
2024-06-22 08:02:23 -05:00

21 lines
564 B
JavaScript

import {expect, test} from 'vitest';
import evaluate from '@/astride/evaluate.js';
import expression from '@/astride/test/expression.js';
test('evaluates await expressions', async () => {
const evaluated = evaluate(await expression('await 1'));
expect(evaluated.async)
.to.equal(true);
expect(await evaluated.value)
.to.equal(1);
});
test('coalesces promises', async () => {
const evaluated = evaluate(await expression('await await await 1'));
expect(evaluated.async)
.to.equal(true);
expect(await evaluated.value)
.to.equal(1);
});