mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 10:33:21 +08:00
Internalize all IM channel implementations
This commit is contained in:
parent
8996476693
commit
bd469f58f8
95 changed files with 25012 additions and 100 deletions
44
test/channels/dingtalk/plugin-host.test.mjs
Normal file
44
test/channels/dingtalk/plugin-host.test.mjs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { apply, createDingtalkHostPlugin, inject, name } from '../../../plugin-src/host/channels/dingtalk/index.mjs';
|
||||
|
||||
function controller() {
|
||||
return {
|
||||
status() { return { bots: [] }; },
|
||||
startProvisioning() {},
|
||||
registrationStatus() {},
|
||||
cancelProvisioning() {},
|
||||
reconnectBot() {},
|
||||
deleteBot() {},
|
||||
approveSender() {},
|
||||
revokeSender() {},
|
||||
};
|
||||
}
|
||||
|
||||
test('Host exports the DingTalk plugin identity and required services', () => {
|
||||
const plugin = createDingtalkHostPlugin({ controller: controller() });
|
||||
assert.equal(name, 'dsh-dingtalk-host');
|
||||
assert.deepEqual(inject, ['connection', 'credentials', 'webServer']);
|
||||
assert.equal(plugin.name, name);
|
||||
assert.deepEqual(plugin.inject, inject);
|
||||
});
|
||||
|
||||
test('Host installs loopback RPC for an injected controller', async () => {
|
||||
const calls = [];
|
||||
const dispose = () => {};
|
||||
const ctx = {
|
||||
connection: {
|
||||
rpc: {
|
||||
handle: (...args) => {
|
||||
calls.push(args);
|
||||
return dispose;
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert.equal(await apply(ctx, { controller: controller() }), dispose);
|
||||
assert.equal(calls[0][0], '/dingtalk');
|
||||
assert.deepEqual(calls[0][2], { authority: 'loopback' });
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue