Skip to content

Commit

Permalink
more test cleanup (#165233)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno authored Nov 2, 2022
1 parent ff51b87 commit cbf6c41
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/vs/base/parts/ipc/test/node/ipc.cp.integrationTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

import * as assert from 'assert';
import { Event } from 'vs/base/common/event';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { Client } from 'vs/base/parts/ipc/node/ipc.cp';
import { getPathFromAmdModule } from 'vs/base/test/node/testUtils';
import { TestServiceClient } from './testService';
import { ITestService, TestServiceClient } from './testService';

function createClient(): Client {
return new Client(getPathFromAmdModule(require, 'bootstrap-fork'), {
Expand All @@ -20,39 +21,37 @@ suite('IPC, Child Process', function () {
this.slow(2000);
this.timeout(10000);

test('createChannel', async () => {
const client = createClient();
const channel = client.getChannel('test');
const service = new TestServiceClient(channel);
let client: Client;
let channel: IChannel;
let service: ITestService;

setup(() => {
client = createClient();
channel = client.getChannel('test');
service = new TestServiceClient(channel);
});

teardown(() => {
client.dispose();
});

test('createChannel', async () => {
const result = await service.pong('ping');
assert.strictEqual(result.incoming, 'ping');
assert.strictEqual(result.outgoing, 'pong');

client.dispose();
});

test('events', async () => {
const client = createClient();
const channel = client.getChannel('test');
const service = new TestServiceClient(channel);

const event = Event.toPromise(Event.once(service.onMarco));
const promise = service.marco();

const [promiseResult, eventResult] = await Promise.all([promise, event]);

assert.strictEqual(promiseResult, 'polo');
assert.strictEqual(eventResult.answer, 'polo');

client.dispose();
});

test('event dispose', async () => {
const client = createClient();
const channel = client.getChannel('test');
const service = new TestServiceClient(channel);

let count = 0;
const disposable = service.onMarco(() => count++);

Expand All @@ -68,7 +67,5 @@ suite('IPC, Child Process', function () {
const answer_2 = await service.marco();
assert.strictEqual(answer_2, 'polo');
assert.strictEqual(count, 2);

client.dispose();
});
});

0 comments on commit cbf6c41

Please sign in to comment.