avocado/packages/behavior/test/builders.js

33 lines
832 B
JavaScript
Raw Normal View History

2021-01-03 20:11:11 -06:00
import {Latus} from '@latus/core';
2021-01-02 22:01:57 -06:00
import {expect} from 'chai';
2021-01-03 20:11:11 -06:00
2021-01-02 22:01:57 -06:00
import {
buildCondition,
buildExpression,
buildValue,
} from '../src/builders';
2021-01-03 20:11:11 -06:00
import Context from '../src/context';
import compile from '../src/compilers/compile';
2021-01-05 11:25:37 -06:00
let latus;
let context;
beforeEach(async () => {
latus = Latus.mock({
'@avocado/behavior': require('../src'),
2021-01-03 20:11:11 -06:00
});
2021-01-05 11:25:37 -06:00
await Promise.all(latus.invokeFlat('@latus/core/starting'));
context = new Context({}, latus);
});
it('builds values', async () => {
const passthroughs = [
buildCondition('is', []),
buildExpression([]),
buildValue(69),
];
for (let i = 0; i < passthroughs.length; i++) {
const passthrough = passthroughs[i];
expect(passthrough).to.equal(buildValue(passthrough));
}
expect(buildValue(420)).to.deep.equal({type: 'literal', value: 420});
2021-01-02 22:01:57 -06:00
});