Fix TS Client tests (#586)

This commit is contained in:
BrennanConroy 2017-06-24 08:39:07 -07:00 committed by GitHub
parent 9602787463
commit 0f264e18e9
3 changed files with 16 additions and 16 deletions

View File

@ -1,7 +1,7 @@
describe('connection', () => { describe('connection', () => {
it(`can connect to the server without specifying transport explicitly`, done => { it(`can connect to the server without specifying transport explicitly`, done => {
const message = "Hello World!"; const message = "Hello World!";
let connection = new signalR.Connection(ECHOENDPOINT_URL); let connection = new signalR.HttpConnection(ECHOENDPOINT_URL);
let received = ""; let received = "";
connection.onDataReceived = data => { connection.onDataReceived = data => {
@ -29,7 +29,7 @@ describe('connection', () => {
eachTransport(transportType => { eachTransport(transportType => {
it(`over ${signalR.TransportType[transportType]} can send and receive messages`, done => { it(`over ${signalR.TransportType[transportType]} can send and receive messages`, done => {
const message = "Hello World!"; const message = "Hello World!";
let connection = new signalR.Connection(ECHOENDPOINT_URL); let connection = new signalR.HttpConnection(ECHOENDPOINT_URL, { transport: transportType });
let received = ""; let received = "";
connection.onDataReceived = data => { connection.onDataReceived = data => {
@ -44,7 +44,7 @@ describe('connection', () => {
done(); done();
} }
connection.start(transportType) connection.start()
.then(() => { .then(() => {
connection.send(message); connection.send(message);
}) })

View File

@ -5,13 +5,13 @@ describe('hubConnection', () => {
describe(`${signalR.TransportType[transportType]} transport`, () => { describe(`${signalR.TransportType[transportType]} transport`, () => {
it(`can invoke server method and receive result`, done => { it(`can invoke server method and receive result`, done => {
const message = "Hi"; const message = "Hi";
let hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, 'formatType=json&format=text'); let hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), 'formatType=json&format=text');
hubConnection.onClosed = error => { hubConnection.onClosed = error => {
expect(error).toBe(undefined); expect(error).toBe(undefined);
done(); done();
} }
hubConnection.start(transportType) hubConnection.start()
.then(() => { .then(() => {
hubConnection.invoke('Echo', message) hubConnection.invoke('Echo', message)
.then(result => { .then(result => {
@ -31,14 +31,14 @@ describe('hubConnection', () => {
}); });
it(`can stream server method and receive result`, done => { it(`can stream server method and receive result`, done => {
let hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, 'formatType=json&format=text'); let hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), 'formatType=json&format=text');
hubConnection.onClosed = error => { hubConnection.onClosed = error => {
expect(error).toBe(undefined); expect(error).toBe(undefined);
done(); done();
} }
let received = []; let received = [];
hubConnection.start(transportType) hubConnection.start()
.then(() => { .then(() => {
hubConnection.stream('Stream') hubConnection.stream('Stream')
.subscribe({ .subscribe({
@ -63,9 +63,9 @@ describe('hubConnection', () => {
it(`rethrows an exception from the server when invoking`, done => { it(`rethrows an exception from the server when invoking`, done => {
const errorMessage = "An error occurred."; const errorMessage = "An error occurred.";
let hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, 'formatType=json&format=text'); let hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), 'formatType=json&format=text');
hubConnection.start(transportType) hubConnection.start()
.then(() => { .then(() => {
hubConnection.invoke('ThrowException', errorMessage) hubConnection.invoke('ThrowException', errorMessage)
.then(() => { .then(() => {
@ -90,9 +90,9 @@ describe('hubConnection', () => {
it(`rethrows an exception from the server when streaming`, done => { it(`rethrows an exception from the server when streaming`, done => {
const errorMessage = "An error occurred."; const errorMessage = "An error occurred.";
let hubConnection = new signalR.HubConnection(TESTHUBENDPOINT_URL, 'formatType=json&format=text'); let hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), 'formatType=json&format=text');
hubConnection.start(transportType) hubConnection.start()
.then(() => { .then(() => {
hubConnection.stream('ThrowException', errorMessage) hubConnection.stream('ThrowException', errorMessage)
.subscribe({ .subscribe({
@ -116,7 +116,7 @@ describe('hubConnection', () => {
}); });
it(`can receive server calls`, done => { it(`can receive server calls`, done => {
let client = new signalR.HubConnection(TESTHUBENDPOINT_URL, 'formatType=json&format=text'); let client = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), 'formatType=json&format=text');
const message = "Hello SignalR"; const message = "Hello SignalR";
let callbackPromise = new Promise((resolve, reject) => { let callbackPromise = new Promise((resolve, reject) => {
@ -126,7 +126,7 @@ describe('hubConnection', () => {
}); });
}); });
client.start(transportType) client.start()
.then(() => { .then(() => {
return Promise.all([client.invoke('InvokeWithString', message), callbackPromise]); return Promise.all([client.invoke('InvokeWithString', message), callbackPromise]);
}) })
@ -150,13 +150,13 @@ describe('hubConnection', () => {
ServerSentEvents: "Error occurred" ServerSentEvents: "Error occurred"
}; };
let hubConnection = new signalR.HubConnection(`http://${document.location.host}/uncreatable`, 'formatType=json&format=text'); let hubConnection = new signalR.HubConnection(new signalR.HttpConnection(`http://${document.location.host}/uncreatable`, { transport: transportType }), 'formatType=json&format=text');
hubConnection.onClosed = error => { hubConnection.onClosed = error => {
expect(error).toMatch(errorRegex[signalR.TransportType[transportType]]); expect(error).toMatch(errorRegex[signalR.TransportType[transportType]]);
done(); done();
} }
hubConnection.start(transportType) hubConnection.start();
}); });
}); });
}); });