本文整理汇总了TypeScript中@jupyterlab/coreutils.PageConfig.getWsUrl方法的典型用法代码示例。如果您正苦于以下问题:TypeScript PageConfig.getWsUrl方法的具体用法?TypeScript PageConfig.getWsUrl怎么用?TypeScript PageConfig.getWsUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@jupyterlab/coreutils.PageConfig
的用法示例。
在下文中一共展示了PageConfig.getWsUrl方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should use default settings', () => {
let settings = ServerConnection.makeSettings();
expect(settings.baseUrl).to.be(PageConfig.getBaseUrl());
expect(settings.wsUrl).to.be(PageConfig.getWsUrl());
expect(settings.user).to.be('');
expect(settings.password).to.be('');
expect(settings.withCredentials).to.be(false);
expect(settings.timeout).to.be(0);
expect(settings.token).to.be(PageConfig.getOption('token'));
expect(Object.keys(settings.requestHeaders).length).to.be(0);
});
示例2: makeSettings
function makeSettings(options: Partial<ServerConnection.ISettings> = {}): ServerConnection.ISettings {
let baseUrl = options.baseUrl || PageConfig.getBaseUrl();
return {
baseUrl,
wsUrl: options.wsUrl || PageConfig.getWsUrl(baseUrl),
user: options.user || '',
password: options.password || '',
withCredentials: !!options.withCredentials,
timeout: options.timeout || 0,
token: options.token || PageConfig.getOption('token'),
requestHeaders: { ...options.requestHeaders || {} },
xhrFactory: options.xhrFactory || xhrFactory,
wsFactory: options.wsFactory || wsFactory
};
}
示例3: it
it('should use default settings', () => {
let settings = ServerConnection.makeSettings();
expect(settings.baseUrl).to.be(PageConfig.getBaseUrl());
expect(settings.wsUrl).to.be(PageConfig.getWsUrl());
expect(settings.token).to.be(PageConfig.getOption('token'));
});
示例4: it
it('should get the base ws url of the page', () => {
// The value was passed as a command line arg.
expect(PageConfig.getWsUrl()).to.contain('ws://localhost');
});
示例5: constructor
/**
* Create a new network error.
*/
constructor(original: TypeError) {
super(original.message);
this.stack = original.stack;
}
}
/**
* The default settings.
*/
export const defaultSettings: ServerConnection.ISettings = {
baseUrl: PageConfig.getBaseUrl(),
pageUrl: PageConfig.getOption('pageUrl'),
wsUrl: PageConfig.getWsUrl(),
token: PageConfig.getToken(),
init: { cache: 'no-store', credentials: 'same-origin' },
fetch: FETCH,
Headers: HEADERS,
Request: REQUEST,
WebSocket: WEBSOCKET
};
}
/**
* The namespace for module private data.
*/
namespace Private {
/**
* Handle the server connection settings, returning a new value.
示例6: it
it('should be an empty string for a bad base url', () => {
const url = 'blargh://foo.com';
expect(PageConfig.getWsUrl(url)).to.equal('');
});