some tests mock window

This commit is contained in:
Paul Fitzpatrick 2024-10-09 23:25:46 -04:00
parent cdd4571a77
commit 0c5efbf756
No known key found for this signature in database
GPG Key ID: 07F16BF3214888F6

View File

@ -75,8 +75,9 @@ export class GristClientSocket {
// if so, secure in the fact that we were in the browser and
// the browser would pass along cookie information. But recent
// node defines WebSocket, so we narrow down this path to when
// window is defined.
if (typeof window !== 'undefined') {
// a global document is defined (window doesn't work because
// some tests mock it).
if (typeof document !== 'undefined') {
this._wsSocket = new WebSocket(this._url);
} else {
this._wsSocket = new WS(this._url, undefined, this._options);