Permalink
Switch branches/tags
v4.0.0 v2.6.2 v2.6.0 v2.5.0 release/4.1.0 release/4.0.0 release/4.0.0-next.1 release/3.5.1 release/3.5.0 release/3.4.2 release/3.4.0 release/3.3.0 release/3.2.1 release/3.2.0 release/3.0.3 release/types/3.13.0 release/types/3.13.0-next.1 release/types/3.12.0 release/types/3.11.0 release/types/3.10.1 release/types/3.10.0 release/types/3.9.0 release/types/3.8.2 release/types/3.8.1 release/types/3.8.0 release/types/3.7.2 release/server/5.1.0 release/server/5.1.0-next.6 release/server/5.1.0-next.5 release/server/5.1.0-next.3 release/server/5.1.0-next.2 release/server/5.1.0-next.1 release/server/5.0.3 release/server/5.0.0 release/server/4.4.1 release/server/4.4.0 release/server/4.3.0 release/server/4.2.1 release/server/4.2.0 release/server/4.1.3 release/server/4.1.2 release/protocol/3.13.0 release/protocol/3.13.0-next.3 release/protocol/3.13.0-next.2 release/protocol/3.13.0-next.1 release/protocol/3.12.0 release/protocol/3.11.0 release/protocol/3.10.5 release/protocol/3.10.4 release/protocol/3.10.1 release/protocol/3.10.0 release/protocol/3.9.0 release/protocol/3.8.1 release/protocol/3.8.0 release/protocol/3.7.2 release/jsonrpc/3.7.0-next.1 release/jsonrpc/3.6.2 release/jsonrpc/3.3.1 release/json-rpc/4.0.0 release/json-rpc/4.0.0-next.1 release/client/5.1.1 release/client/5.1.0 release/client/5.1.0-next.10 release/client/5.1.0-next.7 release/client/5.1.0-next.6 release/client/5.1.0-next.4 release/client/5.1.0-next.3 release/client/5.1.0-next.2 release/client/5.1.0-next.1 release/client/5.0.1 release/client/5.0.0 release/client/4.4.1 release/client/4.4.0 release/client/4.3.0 release/client/4.2.1 release/client/4.2.0 release/client/4.1.4 release/client/4.0.1 list 1.4.x
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (54 sloc) 1.91 KB
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
import * as assert from 'assert';
import { Duplex } from 'stream';
import { InitializeParams, InitializeRequest, InitializeResult, createProtocolConnection, StreamMessageReader, StreamMessageWriter, Logger } from '../main';
class NullLogger implements Logger {
error(_message: string): void {
}
warn(_message: string): void {
}
info(_message: string): void {
}
log(_message: string): void {
}
}
class TestStream extends Duplex {
_write(chunk: string, _encoding: string, done: () => void) {
this.emit('data', chunk);
done();
}
_read(_size: number) {
}
}
describe('Connection Tests', () => {
it('Ensure propert param passing', async() => {
const up = new TestStream();
const down = new TestStream();
const logger = new NullLogger();
const serverConnection = createProtocolConnection(new StreamMessageReader(up), new StreamMessageWriter(down), logger);
const clientConnection = createProtocolConnection(new StreamMessageReader(down), new StreamMessageWriter(up), logger);
serverConnection.listen();
clientConnection.listen();
let paramsCorrect: boolean = false;
serverConnection.onRequest(InitializeRequest.type, (params) => {
paramsCorrect = !Array.isArray(params);
let result: InitializeResult = {
capabilities: {
}
};
return result;
});
const init: InitializeParams = {
rootUri: 'file:///home/dirkb',
processId: 1,
capabilities: {},
workspaceFolders: null,
};
await clientConnection.sendRequest(InitializeRequest.type, init);
assert.ok(paramsCorrect, 'Parameters are transferred correctly');
});
});