mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 18:53:17 +08:00
feat: add plugin version command
This commit is contained in:
parent
10ca7eec2c
commit
c5becbe379
24 changed files with 240 additions and 172 deletions
|
|
@ -36,14 +36,31 @@ function fixture({ sessionId = 'session-one', stopped = true, steered = true } =
|
|||
test('isControlCommand reserves valid and malformed control command forms', () => {
|
||||
for (const value of [
|
||||
'/stop', ' /STOP ', '/stop now', '/steer', '/StEeR do this', '/steer line one\nline two',
|
||||
'/version', ' /VERSION ', '/version now',
|
||||
]) {
|
||||
assert.equal(isControlCommand(value), true, value);
|
||||
}
|
||||
for (const value of [null, '', 'stop', '/stopping', '/steering', 'hello /stop']) {
|
||||
for (const value of [null, '', 'stop', '/stopping', '/steering', '/versions', 'hello /stop']) {
|
||||
assert.equal(isControlCommand(value), false, String(value));
|
||||
}
|
||||
});
|
||||
|
||||
test('/version returns the package version without touching Harness or Session state', async () => {
|
||||
const { calls, harness, state } = fixture();
|
||||
const { version } = await import('../package.json', { with: { type: 'json' } })
|
||||
.then((module) => module.default);
|
||||
|
||||
assert.deepEqual(
|
||||
await runControlCommand('/VERSION', harness, state, 'direct:one'),
|
||||
{ message: `dsh-im v${version}` },
|
||||
);
|
||||
assert.match(
|
||||
(await runControlCommand('/version details', harness, state, 'direct:one')).message,
|
||||
/用法/,
|
||||
);
|
||||
assert.equal(calls.length, 0);
|
||||
});
|
||||
|
||||
test('/stop is exact, text-only, and never creates a Session', async () => {
|
||||
const { calls, harness, state } = fixture();
|
||||
assert.match((await runControlCommand('/stop later', harness, state, 'direct:one')).message, /用法/);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue