End-to-end browser tests
This commit is contained in:
parent
11d8f8ff2b
commit
d3e625c985
|
|
@ -12,6 +12,8 @@ interface InvocationResultDescriptor {
|
||||||
readonly Result: any;
|
readonly Result: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { Connection } from "./Connection"
|
||||||
|
|
||||||
export class HubConnection {
|
export class HubConnection {
|
||||||
private connection: Connection;
|
private connection: Connection;
|
||||||
private callbacks: Map<string, (any) => void>;
|
private callbacks: Map<string, (any) => void>;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server
|
||||||
{
|
{
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddRouting();
|
services.AddSockets();
|
||||||
|
services.AddSignalR();
|
||||||
services.AddSingleton<EchoEndPoint>();
|
services.AddSingleton<EchoEndPoint>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"precompile": [ "npm install", "npm run gulp -- --gulpfile %project:Directory%/gulpfile.js copy-jasmine"],
|
"precompile": [ "npm install",
|
||||||
|
"npm run gulp -- --gulpfile %project:Directory%/gulpfile.js copy-jasmine",
|
||||||
|
"npm run gulp -- --gulpfile %project:Directory%/../../src/Microsoft.AspNetCore.SignalR.Client.TS/gulpfile.js bundle-client --bundleOutDir %project:Directory%/wwwroot/lib/signalr-client/" ],
|
||||||
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
|
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@
|
||||||
<script type="text/javascript" src="lib/jasmine/jasmine.js"></script>
|
<script type="text/javascript" src="lib/jasmine/jasmine.js"></script>
|
||||||
<script type="text/javascript" src="lib/jasmine/jasmine-html.js"></script>
|
<script type="text/javascript" src="lib/jasmine/jasmine-html.js"></script>
|
||||||
<script type="text/javascript" src="lib/jasmine/boot.js"></script>
|
<script type="text/javascript" src="lib/jasmine/boot.js"></script>
|
||||||
|
<script type="text/javascript" src="lib/signalr-client/signalr-client.js"></script>
|
||||||
|
<script src="js/common.js"></script>
|
||||||
<script src="js/webSocketTests.js"></script>
|
<script src="js/webSocketTests.js"></script>
|
||||||
|
<script src="js/connectionTests.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
const ECHOENDPOINT_URL = `http://${document.location.host}/echo`;
|
||||||
|
|
||||||
|
function eachTransport(action) {
|
||||||
|
let transportNames = ["webSockets", "serverSentEvents", "longPolling"];
|
||||||
|
transportNames.forEach(t => action(t));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
describe('connection', () => {
|
||||||
|
eachTransport(transportName => {
|
||||||
|
it(`over ${transportName} can send and receive messages`, done => {
|
||||||
|
const message = "Hello World!";
|
||||||
|
let connection = new signalR.Connection(ECHOENDPOINT_URL);
|
||||||
|
|
||||||
|
let received = "";
|
||||||
|
connection.dataReceived = data => {
|
||||||
|
received += data;
|
||||||
|
if (data == message) {
|
||||||
|
connection.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.connectionClosed = error => {
|
||||||
|
expect(error).toBeUndefined();
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.start(transportName)
|
||||||
|
.then(() => {
|
||||||
|
connection.send(message);
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
expect(true).toBe(false);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
const ECHOENDPOINT_URL = `ws://${document.location.host}/echo/ws`;
|
describe('WebSockets', function () {
|
||||||
|
|
||||||
describe('WebSockets', function () {
|
|
||||||
it('can be used to connect to SignalR', done => {
|
it('can be used to connect to SignalR', done => {
|
||||||
const message = "message";
|
const message = "message";
|
||||||
|
|
||||||
let webSocket = new WebSocket(ECHOENDPOINT_URL);
|
let webSocket = new WebSocket(ECHOENDPOINT_URL.replace(/^http/, "ws") + '/ws');
|
||||||
|
|
||||||
webSocket.onopen = () => {
|
webSocket.onopen = () => {
|
||||||
webSocket.send(message);
|
webSocket.send(message);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue