UNPKG

2.8 kBTypeScriptView Raw
1/// <reference types="jest" />
2import { ISessionContext, SessionContext } from '@jupyterlab/apputils';
3import { Kernel, KernelMessage, ServiceManager, Session } from '@jupyterlab/services';
4import { AttachedProperty } from '@lumino/properties';
5import { ISignal } from '@lumino/signaling';
6import { Context } from './context';
7import { TextModelFactory } from './default';
8import { DocumentRegistry, IDocumentWidget } from './registry';
9/**
10 * Create a context for a file.
11 */
12export declare function createFileContext(path?: string, manager?: ServiceManager.IManager): Context<DocumentRegistry.IModel>;
13export declare function createFileContextWithKernel(path?: string, manager?: ServiceManager.IManager): Promise<Context>;
14export declare function createFileContextWithMockedServices(startKernel?: boolean, manager?: ServiceManager.IManager): Promise<Context>;
15/**
16 * Create a session and return a session connection.
17 */
18export declare function createSession(options: Session.ISessionOptions): Promise<Session.ISessionConnection>;
19/**
20 * Create a session context given a partial session model.
21 *
22 * @param model The session model to use.
23 */
24export declare function createSimpleSessionContext(model?: Private.RecursivePartial<Session.IModel>): ISessionContext;
25/**
26 * Emit an iopub message on a session context.
27 *
28 * @param sessionContext The session context
29 * @param msg Message created with `KernelMessage.createMessage`
30 */
31export declare function emitIopubMessage(context: ISessionContext, msg: KernelMessage.IIOPubMessage): void;
32/**
33 * Forceably change the status of a session context.
34 * An iopub message is emitted for the change.
35 *
36 * @param sessionContext The session context of interest.
37 * @param newStatus The new kernel status.
38 */
39export declare function updateKernelStatus(sessionContext: ISessionContext, newStatus: KernelMessage.Status): void;
40/**
41 * A mock session context.
42 *
43 * @param session The session connection object to use
44 */
45export declare const SessionContextMock: jest.Mock<ISessionContext, [Partial<SessionContext.IOptions>, Session.ISessionConnection | null], any>;
46/**
47 * A namespace for module private data.
48 */
49declare namespace Private {
50 type RecursivePartial<T> = {
51 [P in keyof T]?: RecursivePartial<T[P]>;
52 };
53 const textFactory: TextModelFactory;
54 /**
55 * Get or create the service manager singleton.
56 */
57 function getManager(): ServiceManager;
58 const lastMessageProperty: AttachedProperty<Kernel.IKernelConnection, string>;
59 const RUNNING_KERNELS: Kernel.IKernelConnection[];
60}
61/**
62 * A mock document widget opener.
63 */
64export declare class DocumentWidgetOpenerMock {
65 get opened(): ISignal<DocumentWidgetOpenerMock, IDocumentWidget>;
66 open(widget: IDocumentWidget): void;
67 private _opened;
68}
69export {};