diff --git a/test/commander/commander.test.ts b/test/commander/commander.test.ts index 091157ad..e02b311c 100644 --- a/test/commander/commander.test.ts +++ b/test/commander/commander.test.ts @@ -90,16 +90,29 @@ describe('command center', () => { cc.on('hello', async (ctx) => { console.log(`🚀 ~ file: commander.test.ts:53 ~ cc.on ~ ctx:`, ctx); - ctx.token.onCancellationRequested(() => { - tokenOnCancellationRequested(); - }); - await sleep(4 * 1000); - fn(); + await Promise.race([ + (async () => { + await sleep(5 * 1000); + fn(); + })(), + new Promise((resolve) => { + ctx.token.onCancellationRequested(() => { + tokenOnCancellationRequested(); + resolve(); + }); + }), + ]); }); try { - await cc.tryHandle('/hello', { - name: 'opensumi', - }); + await cc.tryHandle( + '/hello', + { + name: 'opensumi', + }, + { + timeout: 3 * 1000, + }, + ); } catch (error) { expect((error as any).message).toBe('Canceled'); } diff --git a/test/ding/send.test.ts b/test/ding/send.test.ts index 00560f25..11d90261 100644 --- a/test/ding/send.test.ts +++ b/test/ding/send.test.ts @@ -1,7 +1,7 @@ let content: any | undefined; -jest.mock('@/im/utils', () => { +jest.mock('@opensumi/dingtalk-bot/lib/utils', () => { // Require the original module to not be mocked... - const originalModule = jest.requireActual('@/im/utils'); + const originalModule = jest.requireActual('@opensumi/dingtalk-bot/lib/utils'); return { __esModule: true, // Use it when dealing with esModules @@ -14,6 +14,7 @@ jest.mock('@/im/utils', () => { }, }; }); + import { sendContentToDing } from '@/github/utils'; describe('can send content to dingtalk', () => { diff --git a/test/github/utils.test.ts b/test/github/utils.test.ts index d85bd42e..0efc1c34 100644 --- a/test/github/utils.test.ts +++ b/test/github/utils.test.ts @@ -10,7 +10,7 @@ import { parseGitHubUrl, standardizeMarkdown, } from '@/github/utils'; -import * as DingUtils from '@/im/utils'; +import * as DingUtils from '@opensumi/dingtalk-bot/lib/utils'; describe('github utils', () => { it('can limit lines', () => {