forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocolWriter.test.ts
More file actions
30 lines (25 loc) · 1.11 KB
/
protocolWriter.test.ts
File metadata and controls
30 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// tslint:disable:no-any
import { expect } from 'chai';
import { Transform } from 'stream';
import { InitializedEvent } from 'vscode-debugadapter/lib/main';
import { ProtocolMessageWriter } from '../../../client/debugger/debugAdapter/Common/protocolWriter';
suite('Debugging - Protocol Writer', () => {
test('Test request, response and event messages', async () => {
let dataWritten = '';
const throughOutStream = new Transform({
transform: (chunk, _encoding, callback) => {
dataWritten += (chunk as Buffer).toString('utf8');
callback(undefined, chunk);
}
});
const message = new InitializedEvent();
message.seq = 123;
const writer = new ProtocolMessageWriter();
writer.write(throughOutStream, message);
const json = JSON.stringify(message);
const expectedMessage = `Content-Length: ${Buffer.byteLength(json, 'utf8')}\r\n\r\n${json}`;
expect(dataWritten).to.be.equal(expectedMessage);
});
});