Skip to content

Commit

Permalink
fix(test-utils): always strip _async suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 19, 2020
1 parent dfd279c commit 8c3f3cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/plugin-common/tests/broadcast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function nextTick () {

test('basic support', async () => {
await app.receiveMessage('user', 'broadcast foo bar', 123)
app.shouldHaveLastRequest('send_group_msg_async', { message: 'foo bar', groupId: 321 })
app.shouldHaveLastRequest('send_group_msg', { message: 'foo bar', groupId: 321 })
await nextTick()
app.shouldHaveLastRequest('send_group_msg_async', { message: 'foo bar', groupId: 654 })
app.shouldHaveLastRequest('send_group_msg', { message: 'foo bar', groupId: 654 })
})
6 changes: 1 addition & 5 deletions packages/test-utils/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,9 @@ class MockedAppSender extends Sender {
constructor (app: App) {
super(app)
this._get = async (action, params) => {
return this.mock.receive(action, params)
return this.mock.receive(action.replace(/_async$/, ''), params)
}
}

getAsync (action: string, params?: RequestParams) {
return this.get(action, params)
}
}

const createMessageMeta = (type: ContextType, message: string, userId: number, ctxId: number): MessageMeta => ({
Expand Down

0 comments on commit 8c3f3cc

Please sign in to comment.