Skip to content

Commit

Permalink
test: fix testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Dec 3, 2023
1 parent f227fbd commit b656f3c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
29 changes: 21 additions & 8 deletions test/commander/commander.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>((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');
}
Expand Down
5 changes: 3 additions & 2 deletions test/ding/send.test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,6 +14,7 @@ jest.mock('@/im/utils', () => {
},
};
});

import { sendContentToDing } from '@/github/utils';

describe('can send content to dingtalk', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/github/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit b656f3c

Please sign in to comment.