flecks/packages/core/test/gather.js

33 lines
940 B
JavaScript
Raw Normal View History

2022-02-25 04:58:08 -06:00
import {expect} from 'chai';
2022-02-26 09:47:29 -06:00
import {Flecks, ById, ByType} from '@flecks/core';
2022-02-25 04:58:08 -06:00
2024-01-28 08:05:25 -06:00
it('can gather', async () => {
const flecks = await Flecks.from({
2022-02-25 04:58:08 -06:00
flecks: {
2024-02-04 16:01:30 -06:00
one: {
hooks: {
'one.gather': Flecks.provide(require.context('./gather/one', false)),
'one.gather.decorate': Flecks.decorate(require.context('./gather/one/decorators', false)),
},
},
two: {
hooks: {
'one.gather': Flecks.provide(require.context('./gather/two', false)),
},
},
2022-02-25 04:58:08 -06:00
},
});
2024-02-04 16:01:30 -06:00
const Gathered = await flecks.gather('one.gather');
2022-02-25 04:58:08 -06:00
expect(Object.keys(Gathered[ByType]).length)
.to.equal(Object.keys(Gathered[ById]).length);
const typeKeys = Object.keys(Gathered[ByType]);
for (let i = 0; i < typeKeys.length; ++i) {
const type = typeKeys[i];
expect(Gathered[type].foo)
.to.equal(type);
}
expect(typeof Gathered.Three.bar)
2022-03-11 05:50:59 -06:00
.to.not.be.undefined;
2022-02-25 04:58:08 -06:00
});