2021-01-03 21:43:34 -06:00
|
|
|
import {Latus} from '@latus/core';
|
|
|
|
import {expect} from 'chai';
|
|
|
|
|
|
|
|
import {
|
|
|
|
buildInvoke,
|
|
|
|
buildValue,
|
|
|
|
} from '../src/builders';
|
|
|
|
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'),
|
|
|
|
});
|
|
|
|
await Promise.all(latus.invokeFlat('@latus/core/starting'));
|
|
|
|
context = new Context({}, latus);
|
|
|
|
});
|
|
|
|
describe('Utility', () => {
|
|
|
|
it('makes arrays', async () => {
|
|
|
|
expect(compile(buildInvoke(
|
|
|
|
['Utility', 'makeArray'],
|
|
|
|
[
|
|
|
|
buildValue(1),
|
|
|
|
buildValue(2),
|
|
|
|
buildValue(3),
|
|
|
|
],
|
|
|
|
), latus)(context)).to.deep.equal([1, 2, 3]);
|
|
|
|
});
|
|
|
|
it('makes objects', async () => {
|
|
|
|
expect(compile(buildInvoke(
|
|
|
|
['Utility', 'makeObject'],
|
|
|
|
[
|
|
|
|
buildValue('foo'),
|
|
|
|
buildValue(2),
|
|
|
|
buildValue('bar'),
|
|
|
|
buildValue(3),
|
|
|
|
],
|
|
|
|
), latus)(context)).to.deep.equal({foo: 2, bar: 3});
|
2021-01-03 21:43:34 -06:00
|
|
|
});
|
2021-01-05 11:25:37 -06:00
|
|
|
it('merges', async () => {
|
|
|
|
expect(compile(buildInvoke(
|
|
|
|
['Utility', 'merge'],
|
|
|
|
[
|
|
|
|
buildValue({foo: 69, bar: 420}),
|
|
|
|
buildValue({foo: 311, baz: 100}),
|
|
|
|
],
|
|
|
|
), latus)(context)).to.deep.equal({foo: 311, bar: 420, baz: 100});
|
2021-01-03 21:43:34 -06:00
|
|
|
});
|
|
|
|
});
|