Skip to content

Commit

Permalink
test(plugin-common): respondent
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 16, 2020
1 parent 9674079 commit 0497a9a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/plugin-common/tests/respondent.spec.ts
Original file line number Diff line number Diff line change
@@ -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[]>(respondent, [{
match: '挖坑一时爽',
reply: '填坑火葬场',
}, {
match: /^(.+)$/,
reply: (_, action) => `一直${action}一直爽`,
}])

test('basic support', async () => {
await session.shouldHaveReply('挖坑一时爽', '填坑火葬场')
await session.shouldHaveReply('填坑一时爽', '一直填坑一直爽')
await session.shouldHaveNoResponse('填坑一直爽')
})

0 comments on commit 0497a9a

Please sign in to comment.