Checking if window.document defined before trying to resolve url
This commit is contained in:
parent
4f4fb174ea
commit
602ca479b8
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Launch Program",
|
||||||
|
"program": "${workspaceRoot}/client-ts/node_modules/jasmine/bin/jasmine.js",
|
||||||
|
"args": ["JASMINE_CONFIG_PATH=${workspaceRoot}/client-ts/Microsoft.AspNetCore.SignalR.Client.TS.Tests/jasmine.json"],
|
||||||
|
"cwd": "${workspaceRoot}/client-ts",
|
||||||
|
"outFiles": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Attach to Port",
|
||||||
|
"address": "localhost",
|
||||||
|
"port": 5858,
|
||||||
|
"outFiles": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,13 @@ describe("Connection", () => {
|
||||||
.toThrow(new Error("Cannot resolve '/test'."));
|
.toThrow(new Error("Cannot resolve '/test'."));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("cannot be created with relative url if window object is not present", () => {
|
||||||
|
(<any>global).window = {};
|
||||||
|
expect(() => new HttpConnection("/test"))
|
||||||
|
.toThrow(new Error("Cannot resolve '/test'."));
|
||||||
|
delete (<any>global).window;
|
||||||
|
});
|
||||||
|
|
||||||
it("starting connection fails if getting id fails", async (done) => {
|
it("starting connection fails if getting id fails", async (done) => {
|
||||||
let options: IHttpConnectionOptions = {
|
let options: IHttpConnectionOptions = {
|
||||||
httpClient: <IHttpClient>{
|
httpClient: <IHttpClient>{
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ export class HttpConnection implements IConnection {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined' || !window || !window.document) {
|
||||||
throw new Error(`Cannot resolve '${url}'.`);
|
throw new Error(`Cannot resolve '${url}'.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue