Commit 8c765efd authored by nanahira's avatar nanahira

fix export

parent c0ed61e6
export * from './src/decorators';
export * from './src/def';
export * from './src/decorators';
export * from './src/def';
export * from './src/registrar';
export * from './src/registrar-aspect';
export * from './src/plugin-factory';
export * from './src/utility/get-schema';
import { DefinePlugin, StarterPlugin, UseEvent } from './utility/decorators';
import { SchemaProperty } from 'schemastery-gen';
import { If } from '../src/decorators';
import { For, If } from '../src/decorators';
import { Context } from 'cordis';
class MyConfig {
@SchemaProperty()
foo: boolean;
@SchemaProperty({ type: String })
colors: string[];
}
declare module 'cordis' {
......@@ -21,6 +24,13 @@ class MyPlugin extends StarterPlugin(MyConfig) {
onFoo() {
return 'bar';
}
@For<MyPlugin>(({ config }) => config.colors.map((color) => ({ color })))
@If<MyPlugin>((_, def) => def.color !== 'badthing')
@UseEvent('{{color}}' as any)
onColor() {
return 'good';
}
}
describe('Caller', () => {
......@@ -39,4 +49,11 @@ describe('Caller', () => {
app.plugin(MyPlugin, { foo: false });
expect(app.bail('foo')).toBeUndefined();
});
it('register with array', async () => {
app.plugin(MyPlugin, { colors: ['red', 'blue', 'badthing'] });
expect(app.bail('red' as any)).toBe('good');
expect(app.bail('blue' as any)).toBe('good');
expect(app.bail('badthing' as any)).toBeUndefined();
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment