End-to-end browser tests

This commit is contained in:
moozzyk 2016-11-29 17:50:22 -08:00
parent 11d8f8ff2b
commit d3e625c985
7 changed files with 49 additions and 6 deletions

View File

@ -12,6 +12,8 @@ interface InvocationResultDescriptor {
readonly Result: any;
}
export { Connection } from "./Connection"
export class HubConnection {
private connection: Connection;
private callbacks: Map<string, (any) => void>;

View File

@ -9,7 +9,8 @@ namespace Microsoft.AspNetCore.SignalR.Test.Server
{
public void ConfigureServices(IServiceCollection services)
{
services.AddRouting();
services.AddSockets();
services.AddSignalR();
services.AddSingleton<EchoEndPoint>();
}

View File

@ -39,7 +39,9 @@
},
"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%" ]
}
}

View File

@ -8,7 +8,10 @@
<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/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/connectionTests.js"></script>
</head>
<body>
</body>

View File

@ -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));
}

View File

@ -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();
});
});
});
});

View File

@ -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 => {
const message = "message";
let webSocket = new WebSocket(ECHOENDPOINT_URL);
let webSocket = new WebSocket(ECHOENDPOINT_URL.replace(/^http/, "ws") + '/ws');
webSocket.onopen = () => {
webSocket.send(message);