From 0497a9a9bd92678dbcd412baf76729d7ecd55714 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Thu, 16 Jan 2020 21:09:26 +0800 Subject: [PATCH] test(plugin-common): respondent --- .../plugin-common/tests/respondent.spec.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 packages/plugin-common/tests/respondent.spec.ts diff --git a/packages/plugin-common/tests/respondent.spec.ts b/packages/plugin-common/tests/respondent.spec.ts new file mode 100644 index 0000000000..2f8289ef04 --- /dev/null +++ b/packages/plugin-common/tests/respondent.spec.ts @@ -0,0 +1,21 @@ +import { MockedApp } from 'koishi-test-utils' +import respondent, { Respondent } from '../src/respondent' + +const app = new MockedApp() +const session = app.createSession('user', 123) + +// make coverage happy +app.plugin(respondent) +app.plugin(respondent, [{ + match: '挖坑一时爽', + reply: '填坑火葬场', +}, { + match: /^(.+)一时爽$/, + reply: (_, action) => `一直${action}一直爽`, +}]) + +test('basic support', async () => { + await session.shouldHaveReply('挖坑一时爽', '填坑火葬场') + await session.shouldHaveReply('填坑一时爽', '一直填坑一直爽') + await session.shouldHaveNoResponse('填坑一直爽') +})