Commit e8af0be3 authored by nanahira's avatar nanahira

add unittest

parent 2c25ae0f
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0", "@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0",
"@koishijs/plugin-cache-lru": "^1.0.0-rc.0",
"@types/jest": "^27.0.3", "@types/jest": "^27.0.3",
"@types/lodash": "^4.14.177", "@types/lodash": "^4.14.177",
"@types/node": "^16.11.9", "@types/node": "^16.11.9",
...@@ -1053,18 +1052,6 @@ ...@@ -1053,18 +1052,6 @@
"koishi": "^4.0.0-rc.0" "koishi": "^4.0.0-rc.0"
} }
}, },
"node_modules/@koishijs/plugin-cache-lru": {
"version": "1.0.0-rc.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-rc.0.tgz",
"integrity": "sha512-Mn95Ta8lKmxHacusnQ+uWaCYJHpkw/jzf8vwALH14ZnnC5kxcmTxh7hT8hMp48UpJNHpEIsuNQt91w8RJ4vpXg==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"peerDependencies": {
"koishi": "^4.0.0-rc.0"
}
},
"node_modules/@koishijs/utils": { "node_modules/@koishijs/utils": {
"version": "5.0.0-rc.0", "version": "5.0.0-rc.0",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-rc.0.tgz", "resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-rc.0.tgz",
...@@ -7577,15 +7564,6 @@ ...@@ -7577,15 +7564,6 @@
"ws": "^8.2.1" "ws": "^8.2.1"
} }
}, },
"@koishijs/plugin-cache-lru": {
"version": "1.0.0-rc.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-rc.0.tgz",
"integrity": "sha512-Mn95Ta8lKmxHacusnQ+uWaCYJHpkw/jzf8vwALH14ZnnC5kxcmTxh7hT8hMp48UpJNHpEIsuNQt91w8RJ4vpXg==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
}
},
"@koishijs/utils": { "@koishijs/utils": {
"version": "5.0.0-rc.0", "version": "5.0.0-rc.0",
"resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-rc.0.tgz", "resolved": "https://registry.npmjs.org/@koishijs/utils/-/utils-5.0.0-rc.0.tgz",
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0", "@koishijs/plugin-adapter-onebot": "^4.0.0-rc.0",
"@koishijs/plugin-cache-lru": "^1.0.0-rc.0",
"@types/jest": "^27.0.3", "@types/jest": "^27.0.3",
"@types/lodash": "^4.14.177", "@types/lodash": "^4.14.177",
"@types/node": "^16.11.9", "@types/node": "^16.11.9",
......
...@@ -2,28 +2,30 @@ import { App } from 'koishi'; ...@@ -2,28 +2,30 @@ import { App } from 'koishi';
import { DefinePlugin } from '../src/register'; import { DefinePlugin } from '../src/register';
import { UsePlugin } from '../src/decorators'; import { UsePlugin } from '../src/decorators';
import { PluginDef } from '../src/def'; import { PluginDef } from '../src/def';
import PluginLru from '@koishijs/plugin-cache-lru';
import PluginOnebot from '@koishijs/plugin-adapter-onebot'; import PluginOnebot from '@koishijs/plugin-adapter-onebot';
import { BasePlugin } from '../src/base-plugin';
@DefinePlugin() @DefinePlugin()
class MyPlugin { class MyPlugin extends BasePlugin<any> {
@UsePlugin()
loadLru() {
return PluginDef(PluginLru);
}
@UsePlugin() @UsePlugin()
loadOnebot() { loadOnebot() {
return PluginDef(PluginOnebot, { bots: [] }); return PluginDef(PluginOnebot, {
bots: [{ protocol: 'wsreverse', selfId: '11111' }],
});
} }
} }
describe('Inner plugin', () => { describe('Inner plugin', () => {
let app: App; let app: App;
beforeEach(() => { beforeEach(async () => {
app = new App(); app = new App({ port: 11111 });
await app.start();
// app.plugin(PluginOnebot, { bots: [] }); // app.plugin(PluginOnebot, { bots: [] });
}); });
it('should load inner plugin properly', () => {}); it('should load inner plugin properly', () => {
app.plugin(MyPlugin);
expect(app.bots.length).toBe(1);
//expect(app.cache).toBeDefined();
});
}); });
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