Commit b1e5696c authored by nanahira's avatar nanahira

add unit test

parent fd43b64a
Pipeline #12511 passed with stages
in 1 minute and 23 seconds
import { Context } from 'koishi'; import { Context } from 'koishi';
import { KoishiPluginRegistrationOptions, PluginClass } from '../register'; import { PluginClass } from '../register';
export * from 'koishi-decorators/dist/src/def/interfaces'; export * from 'koishi-decorators/dist/src/def/interfaces';
......
import { App, Context } from 'koishi'; import { App, Context, Logger } from 'koishi';
import { import {
DefinePlugin, DefinePlugin,
OnApply, OnApply,
OnConnect, OnConnect,
OnDisconnect, OnDisconnect,
} from '../src/register'; } from '../src/register';
import { Inject, InjectContext, Provide } from '../src/decorators'; import {
Inject,
InjectContext,
Provide,
InjectLogger,
} from '../src/decorators';
declare module 'koishi' { declare module 'koishi' {
// eslint-disable-next-line @typescript-eslint/no-namespace // eslint-disable-next-line @typescript-eslint/no-namespace
...@@ -32,6 +37,9 @@ class TestingBase implements OnConnect, OnDisconnect, OnApply { ...@@ -32,6 +37,9 @@ class TestingBase implements OnConnect, OnDisconnect, OnApply {
@InjectContext() @InjectContext()
ctx: Context; ctx: Context;
@InjectLogger()
logger: Logger;
onApply() { onApply() {
this.applied = true; this.applied = true;
} }
...@@ -98,4 +106,10 @@ describe('Apply and Connect in koishi-thirdeye', () => { ...@@ -98,4 +106,10 @@ describe('Apply and Connect in koishi-thirdeye', () => {
app.plugin(MyPlugin3); app.plugin(MyPlugin3);
await RunApplyTest(app); await RunApplyTest(app);
}); });
it('should name logger correctly', () => {
app.plugin(MyPlugin);
const myPlugin = app.myPlugin;
expect(myPlugin.logger.name).toBe('MyPlugin');
});
}); });
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