Skip to content

Commit

Permalink
Adopt runWithFakedTimers to speed up tests (microsoft#149712) (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima authored and wannieman98 committed May 17, 2022
1 parent 9e42fe1 commit 6072f56
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/vs/workbench/api/test/browser/extHostTreeViews.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { TreeItemCollapsibleState, ITreeItem, IRevealOptions } from 'vs/workbenc
import { NullLogService } from 'vs/platform/log/common/log';
import type { IDisposable } from 'vs/base/common/lifecycle';
import { nullExtensionDescription as extensionsDescription } from 'vs/workbench/services/extensions/common/extensions';
import { runWithFakedTimers } from 'vs/base/test/common/timeTravelScheduler';

suite('ExtHostTreeView', function () {

Expand Down Expand Up @@ -250,15 +251,17 @@ suite('ExtHostTreeView', function () {
});

async function runWithEventMerging(action: (resolve: () => void) => void) {
await new Promise<void>((resolve) => {
let subscription: IDisposable | undefined = undefined;
subscription = target.onRefresh.event(() => {
subscription!.dispose();
resolve();
await runWithFakedTimers({}, async () => {
await new Promise<void>((resolve) => {
let subscription: IDisposable | undefined = undefined;
subscription = target.onRefresh.event(() => {
subscription!.dispose();
resolve();
});
onDidChangeTreeNode.fire(getNode('b'));
});
onDidChangeTreeNode.fire(getNode('b'));
await new Promise<void>(action);
});
await new Promise<void>(action);
}

test('refresh parent and child node trigger refresh only on parent - scenario 1', async () => {
Expand Down

0 comments on commit 6072f56

Please sign in to comment.