|
1 | 1 | // Copyright (c) .NET Foundation. All rights reserved.
|
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
3 | 3 |
|
4 |
| -import { HttpConnection, LogLevel, TransportType } from "@aspnet/signalr" |
5 |
| -import { eachTransport, ECHOENDPOINT_URL } from "./Common" |
| 4 | +import { HttpConnection, LogLevel, TransportType } from "@aspnet/signalr"; |
| 5 | +import { eachTransport, ECHOENDPOINT_URL } from "./Common"; |
6 | 6 |
|
7 |
| -describe('connection', function () { |
8 |
| - if (typeof WebSocket !== 'undefined') { |
9 |
| - it("can connect to the server without specifying transport explicitly", function (done) { |
10 |
| - var message = "Hello World!"; |
11 |
| - var connection = new HttpConnection(ECHOENDPOINT_URL); |
| 7 | +describe("connection", () => { |
| 8 | + if (typeof WebSocket !== "undefined") { |
| 9 | + it("can connect to the server without specifying transport explicitly", (done) => { |
| 10 | + const message = "Hello World!"; |
| 11 | + const connection = new HttpConnection(ECHOENDPOINT_URL); |
12 | 12 |
|
13 |
| - var received = ""; |
14 |
| - connection.onreceive = function (data) { |
| 13 | + let received = ""; |
| 14 | + connection.onreceive = (data) => { |
15 | 15 | received += data;
|
16 |
| - if (data == message) { |
| 16 | + if (data === message) { |
17 | 17 | connection.stop();
|
18 | 18 | }
|
19 | 19 | };
|
20 | 20 |
|
21 |
| - connection.onclose = function (error) { |
| 21 | + connection.onclose = (error) => { |
22 | 22 | expect(error).toBeUndefined();
|
23 | 23 | done();
|
24 | 24 | };
|
25 | 25 |
|
26 |
| - connection.start().then(function () { |
| 26 | + connection.start().then(() => { |
27 | 27 | connection.send(message);
|
28 |
| - }).catch(function (e) { |
| 28 | + }).catch((e) => { |
29 | 29 | fail();
|
30 | 30 | done();
|
31 | 31 | });
|
32 | 32 | });
|
33 | 33 | }
|
34 | 34 |
|
35 |
| - eachTransport(function (transportType) { |
36 |
| - it("over " + TransportType[transportType] + " can send and receive messages", function (done) { |
37 |
| - var message = "Hello World!"; |
| 35 | + eachTransport((transportType) => { |
| 36 | + it("over " + TransportType[transportType] + " can send and receive messages", (done) => { |
| 37 | + const message = "Hello World!"; |
38 | 38 | // the url should be resolved relative to the document.location.host
|
39 | 39 | // and the leading '/' should be automatically added to the url
|
40 |
| - var connection = new HttpConnection("echo", { |
| 40 | + const connection = new HttpConnection("echo", { |
| 41 | + logger: LogLevel.Trace, |
41 | 42 | transport: transportType,
|
42 |
| - logger: LogLevel.Trace |
43 | 43 | });
|
44 | 44 |
|
45 |
| - var received = ""; |
46 |
| - connection.onreceive = function (data) { |
| 45 | + let received = ""; |
| 46 | + connection.onreceive = (data) => { |
47 | 47 | received += data;
|
48 |
| - if (data == message) { |
| 48 | + if (data === message) { |
49 | 49 | connection.stop();
|
50 | 50 | }
|
51 | 51 | };
|
52 | 52 |
|
53 |
| - connection.onclose = function (error) { |
| 53 | + connection.onclose = (error) => { |
54 | 54 | expect(error).toBeUndefined();
|
55 | 55 | done();
|
56 | 56 | };
|
57 | 57 |
|
58 |
| - connection.start().then(function () { |
| 58 | + connection.start().then(() => { |
59 | 59 | connection.send(message);
|
60 |
| - }).catch(function (e) { |
| 60 | + }).catch((e) => { |
61 | 61 | fail();
|
62 | 62 | done();
|
63 | 63 | });
|
|
0 commit comments