silphius/app/astride/evaluators/await.test.js

21 lines
564 B
JavaScript
Raw Normal View History

2024-06-16 08:01:01 -05:00
import {expect, test} from 'vitest';
import evaluate from '@/astride/evaluate.js';
import expression from '@/astride/test/expression.js';
2024-06-16 08:01:01 -05:00
test('evaluates await expressions', async () => {
2024-06-18 21:46:51 -05:00
const evaluated = evaluate(await expression('await 1'));
2024-06-16 08:01:01 -05:00
expect(evaluated.async)
.to.equal(true);
expect(await evaluated.value)
.to.equal(1);
});
test('coalesces promises', async () => {
2024-06-18 21:46:51 -05:00
const evaluated = evaluate(await expression('await await await 1'));
2024-06-16 08:01:01 -05:00
expect(evaluated.async)
.to.equal(true);
expect(await evaluated.value)
.to.equal(1);
});