Commit 2e398038 authored by nanahira's avatar nanahira

test for inner plugin

parent f8f278ee
......@@ -16,6 +16,7 @@
"typed-reflector": "^1.0.9"
},
"devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0",
"@koishijs/plugin-mock": "^1.0.0",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.178",
......@@ -1011,6 +1012,40 @@
"node": ">=12.0.0"
}
},
"node_modules/@koishijs/plugin-adapter-onebot": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0.tgz",
"integrity": "sha512-xFEBXk9mWgIL1jxdWmbdDc3Y3sB0642vuffWw1tHUh3hz9/aDPRKpONgk94lAfEaCpLB4KMl2V5355Wufu/1Jw==",
"dev": true,
"dependencies": {
"qface": "^1.2.0",
"ws": "^8.2.1"
},
"peerDependencies": {
"koishi": "^4.0.0"
}
},
"node_modules/@koishijs/plugin-adapter-onebot/node_modules/ws": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
"integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
"dev": true,
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/@koishijs/plugin-mock": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-mock/-/plugin-mock-1.0.0.tgz",
......@@ -5445,6 +5480,12 @@
"node": ">=6"
}
},
"node_modules/qface": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/qface/-/qface-1.2.0.tgz",
"integrity": "sha512-MZX1YphF8AXwYKwR7xS1pHar1+bNW86sN+TytI1OidLyDg4ptWzWkyY65lat1UoYzVbKkOU4KySKTbPmYDHzpg==",
"dev": true
},
"node_modules/qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
......@@ -7528,6 +7569,25 @@
"schemastery": "^2.1.3"
}
},
"@koishijs/plugin-adapter-onebot": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-adapter-onebot/-/plugin-adapter-onebot-4.0.0.tgz",
"integrity": "sha512-xFEBXk9mWgIL1jxdWmbdDc3Y3sB0642vuffWw1tHUh3hz9/aDPRKpONgk94lAfEaCpLB4KMl2V5355Wufu/1Jw==",
"dev": true,
"requires": {
"qface": "^1.2.0",
"ws": "^8.2.1"
},
"dependencies": {
"ws": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.4.2.tgz",
"integrity": "sha512-Kbk4Nxyq7/ZWqr/tarI9yIt/+iNNFOjBXEWgTb4ydaNHBNGgvf2QHbS9fdfsndfjFlFwEd4Al+mw83YkaD10ZA==",
"dev": true,
"requires": {}
}
}
},
"@koishijs/plugin-mock": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-mock/-/plugin-mock-1.0.0.tgz",
......@@ -10938,6 +10998,12 @@
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
"dev": true
},
"qface": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/qface/-/qface-1.2.0.tgz",
"integrity": "sha512-MZX1YphF8AXwYKwR7xS1pHar1+bNW86sN+TytI1OidLyDg4ptWzWkyY65lat1UoYzVbKkOU4KySKTbPmYDHzpg==",
"dev": true
},
"qs": {
"version": "6.10.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz",
......
......@@ -39,6 +39,7 @@
"testEnvironment": "node"
},
"devDependencies": {
"@koishijs/plugin-adapter-onebot": "^4.0.0",
"@koishijs/plugin-mock": "^1.0.0",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.178",
......
import { App } from 'koishi';
import { PluginDef } from '../src/def';
import { UsePlugin } from '../src/decorators';
import PluginOnebot from '@koishijs/plugin-adapter-onebot';
import { Registrar } from '../src/register';
class MyClass {
@UsePlugin()
loadOnebot() {
return PluginDef(PluginOnebot, {
bots: [{ protocol: 'wsreverse', selfId: '11111' }],
});
}
}
describe('Inner plugin', () => {
let app: App;
beforeEach(async () => {
app = new App({ port: 11111 });
await app.start();
// app.plugin(PluginOnebot, { bots: [] });
});
it('should load inner plugin properly', () => {
new Registrar(new MyClass()).register(app, 'loadOnebot');
expect(app.bots.length).toBe(1);
});
});
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