From 8c3f3cc7e264e35c505b3aa80906572c493bbf61 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Sun, 19 Jan 2020 23:54:24 +0800 Subject: [PATCH] fix(test-utils): always strip _async suffix --- packages/plugin-common/tests/broadcast.spec.ts | 4 ++-- packages/test-utils/src/mocks.ts | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/plugin-common/tests/broadcast.spec.ts b/packages/plugin-common/tests/broadcast.spec.ts index 346e94441a..bbde1a8ef0 100644 --- a/packages/plugin-common/tests/broadcast.spec.ts +++ b/packages/plugin-common/tests/broadcast.spec.ts @@ -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 }) }) diff --git a/packages/test-utils/src/mocks.ts b/packages/test-utils/src/mocks.ts index 90bb2bd473..1e1a4794a5 100644 --- a/packages/test-utils/src/mocks.ts +++ b/packages/test-utils/src/mocks.ts @@ -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 => ({