Fix TS Client tests (#586)
This commit is contained in:
parent
9602787463
commit
0f264e18e9
|
|
@ -45,7 +45,7 @@ export class HttpConnection implements IConnection {
|
|||
|
||||
private async startInternal(): Promise<void> {
|
||||
try {
|
||||
let negotiatePayload = await this.httpClient.options(this.url);
|
||||
let negotiatePayload = await this.httpClient.options(this.url);
|
||||
let negotiateResponse: INegotiateResponse = JSON.parse(negotiatePayload);
|
||||
this.connectionId = negotiateResponse.connectionId;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
describe('connection', () => {
|
||||
it(`can connect to the server without specifying transport explicitly`, done => {
|
||||
const message = "Hello World!";
|
||||
let connection = new signalR.Connection(ECHOENDPOINT_URL);
|
||||
let connection = new signalR.HttpConnection(ECHOENDPOINT_URL);
|
||||
|
||||
let received = "";
|
||||
connection.onDataReceived = data => {
|
||||
|
|
@ -29,7 +29,7 @@ describe('connection', () => {
|
|||
eachTransport(transportType => {
|
||||
it(`over ${signalR.TransportType[transportType]} can send and receive messages`, done => {
|
||||
const message = "Hello World!";
|
||||
let connection = new signalR.Connection(ECHOENDPOINT_URL);
|
||||
let connection = new signalR.HttpConnection(ECHOENDPOINT_URL, { transport: transportType });
|
||||
|
||||
let received = "";
|
||||
connection.onDataReceived = data => {
|
||||
|
|
@ -44,7 +44,7 @@ describe('connection', () => {
|
|||
done();
|
||||
}
|
||||
|
||||
connection.start(transportType)
|
||||
connection.start()
|
||||
.then(() => {
|
||||
connection.send(message);
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ describe('hubConnection', () => {
|
|||
describe(`${signalR.TransportType[transportType]} transport`, () => {
|
||||
it(`can invoke server method and receive result`, done => {
|
||||
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 => {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
}
|
||||
|
||||
hubConnection.start(transportType)
|
||||
hubConnection.start()
|
||||
.then(() => {
|
||||
hubConnection.invoke('Echo', message)
|
||||
.then(result => {
|
||||
|
|
@ -31,14 +31,14 @@ describe('hubConnection', () => {
|
|||
});
|
||||
|
||||
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 => {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
}
|
||||
|
||||
let received = [];
|
||||
hubConnection.start(transportType)
|
||||
hubConnection.start()
|
||||
.then(() => {
|
||||
hubConnection.stream('Stream')
|
||||
.subscribe({
|
||||
|
|
@ -63,9 +63,9 @@ describe('hubConnection', () => {
|
|||
|
||||
it(`rethrows an exception from the server when invoking`, done => {
|
||||
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(() => {
|
||||
hubConnection.invoke('ThrowException', errorMessage)
|
||||
.then(() => {
|
||||
|
|
@ -90,9 +90,9 @@ describe('hubConnection', () => {
|
|||
|
||||
it(`rethrows an exception from the server when streaming`, done => {
|
||||
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(() => {
|
||||
hubConnection.stream('ThrowException', errorMessage)
|
||||
.subscribe({
|
||||
|
|
@ -116,7 +116,7 @@ describe('hubConnection', () => {
|
|||
});
|
||||
|
||||
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";
|
||||
|
||||
let callbackPromise = new Promise((resolve, reject) => {
|
||||
|
|
@ -126,7 +126,7 @@ describe('hubConnection', () => {
|
|||
});
|
||||
});
|
||||
|
||||
client.start(transportType)
|
||||
client.start()
|
||||
.then(() => {
|
||||
return Promise.all([client.invoke('InvokeWithString', message), callbackPromise]);
|
||||
})
|
||||
|
|
@ -150,13 +150,13 @@ describe('hubConnection', () => {
|
|||
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 => {
|
||||
expect(error).toMatch(errorRegex[signalR.TransportType[transportType]]);
|
||||
done();
|
||||
}
|
||||
hubConnection.start(transportType)
|
||||
hubConnection.start();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue