Skip to content

Commit f625317

Browse files
Added missing require for 'session' tests that relied on 'harness.ts'.
1 parent 6557142 commit f625317

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

tests/cases/unittests/session.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/// <reference path="..\..\..\src\harness\harness.ts" />
22

3+
var expect: typeof _chai.expect = _chai.expect;
4+
35
namespace ts.server {
46
let lastWrittenToHost: string;
57
const mockHost: ServerHost = {
@@ -28,7 +30,7 @@ namespace ts.server {
2830
endGroup(): void {},
2931
msg(s: string, type?: string): void {},
3032
};
31-
33+
3234
describe("the Session class", () => {
3335
let session: Session;
3436
let lastSent: protocol.Message;
@@ -204,7 +206,7 @@ namespace ts.server {
204206
.to.throw(`Protocol handler already exists for command "${command}"`);
205207
});
206208
});
207-
209+
208210
describe("event", () => {
209211
it("can format event responses and send them", () => {
210212
const evt = "notify-test";
@@ -315,15 +317,15 @@ namespace ts.server {
315317
responseRequired: true
316318
}));
317319
}
318-
320+
319321
send(msg: protocol.Message) {
320322
this.client.handle(msg);
321323
}
322324

323325
enqueue(msg: protocol.Request) {
324326
this.queue.unshift(msg);
325327
}
326-
328+
327329
handleRequest(msg: protocol.Request) {
328330
let response: protocol.Response;
329331
try {
@@ -345,7 +347,7 @@ namespace ts.server {
345347
}
346348
}
347349
}
348-
350+
349351
class InProcClient {
350352
private server: InProcSession;
351353
private seq = 0;
@@ -379,7 +381,7 @@ namespace ts.server {
379381
connect(session: InProcSession): void {
380382
this.server = session;
381383
}
382-
384+
383385
execute(command: string, args: any, callback: (resp: protocol.Response) => void): void {
384386
if (!this.server) {
385387
return;
@@ -394,39 +396,39 @@ namespace ts.server {
394396
this.callbacks[this.seq] = callback;
395397
}
396398
};
397-
399+
398400
it("can be constructed and respond to commands", (done) => {
399401
const cli = new InProcClient();
400402
const session = new InProcSession(cli);
401403
const toEcho = {
402404
data: true
403405
};
404406
const toEvent = {
405-
data: false
407+
data: false
406408
};
407409
let responses = 0;
408410

409411
// Connect the client
410412
cli.connect(session);
411-
413+
412414
// Add an event handler
413415
cli.on("testevent", (eventinfo) => {
414416
expect(eventinfo).to.equal(toEvent);
415417
responses++;
416418
expect(responses).to.equal(1);
417419
});
418-
420+
419421
// Trigger said event from the server
420422
session.event(toEvent, "testevent");
421-
423+
422424
// Queue an echo command
423425
cli.execute("echo", toEcho, (resp) => {
424426
assert(resp.success, resp.message);
425427
responses++;
426428
expect(responses).to.equal(2);
427429
expect(resp.body).to.deep.equal(toEcho);
428430
});
429-
431+
430432
// Queue a configure command
431433
cli.execute("configure", {
432434
hostInfo: "unit test",
@@ -436,10 +438,10 @@ namespace ts.server {
436438
}, (resp) => {
437439
assert(resp.success, resp.message);
438440
responses++;
439-
expect(responses).to.equal(3);
441+
expect(responses).to.equal(3);
440442
done();
441443
});
442-
444+
443445
// Consume the queue and trigger the callbacks
444446
session.consumeQueue();
445447
});

0 commit comments

Comments
 (0)