2024-06-16 08:01:01 -05:00
|
|
|
import {expect, test} from 'vitest';
|
|
|
|
|
2024-06-22 08:02:23 -05:00
|
|
|
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);
|
|
|
|
});
|