本文整理汇总了TypeScript中@phosphor/coreutils.UUID类的典型用法代码示例。如果您正苦于以下问题:TypeScript UUID类的具体用法?TypeScript UUID怎么用?TypeScript UUID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UUID类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should be emitted for an unhandled message', async () => {
const kernel = await tester.start();
const msgId = UUID.uuid4();
const emission = testEmission(kernel.anyMessage, {
test: (k, args) => {
expect(args.msg.header.msg_id).to.equal(msgId);
expect(args.msg.header.msg_type).to.equal('foo');
expect(args.direction).to.equal('recv');
}
});
const msg = KernelMessage.createShellMessage({
msgType: 'foo',
channel: 'shell',
session: tester.serverSessionId,
msgId
});
msg.parent_header = { session: kernel.clientId };
tester.send(msg);
await emission;
});
示例2: it
it('should keep the file if overwrite is aborted', async () => {
const oldPath = context.path;
const newPath = UUID.uuid4() + '.txt';
const func = async () => {
await waitForDialog();
const dialog = document.body.getElementsByClassName('jp-Dialog')[0];
const input = dialog.getElementsByTagName('input')[0];
input.value = newPath;
await acceptDialog(); // Accept rename dialog
await dismissDialog(); // Reject conflict dialog
};
await manager.contents.save(newPath, {
type: factory.contentType,
format: factory.fileFormat,
content: 'foo'
});
await context.initialize(true);
const promise = func();
await context.saveAs();
await promise;
expect(context.path).to.equal(oldPath);
});
示例3: it
it('should send a binary message', async () => {
const tester = new KernelTester();
const kernel = await tester.start();
const done = new PromiseDelegate<void>();
const msgId = UUID.uuid4();
tester.onMessage(msg => {
try {
const decoder = new TextDecoder('utf8');
const item = msg.buffers[0] as DataView;
expect(decoder.decode(item)).to.equal('hello');
} catch (e) {
done.reject(e);
throw e;
}
done.resolve(null);
});
const options: KernelMessage.IOptions = {
msgType: 'custom',
channel: 'shell',
username: kernel.username,
session: kernel.clientId,
msgId
};
const encoder = new TextEncoder();
const data = encoder.encode('hello');
const msg = KernelMessage.createShellMessage(options, {}, {}, [
data,
data.buffer
]);
kernel.sendShellMessage(msg, true);
await done.promise;
await tester.shutdown();
tester.dispose();
});
示例4: beforeAll
beforeAll(async () => {
session = await Session.startNew({ path: UUID.uuid4() });
await session.kernel.ready;
});
示例5: it
it('should start a session', async () => {
const session = await manager.startNew({ path: UUID.uuid4() });
await session.kernel.ready;
expect(session.id).to.be.ok;
return session.shutdown();
});
示例6: startNew
/**
* Start a new session with a unique name.
*/
function startNew(): Promise<Session.ISession> {
return Session.startNew({ path: UUID.uuid4() });
}
示例7: it
it('should accept ajax options', async () => {
const serverSettings = makeSettings();
const options: Session.IOptions = { path: UUID.uuid4(), serverSettings };
session = await Session.startNew(options);
expect(session.id).to.be.ok;
});
示例8: it
it('should fail if the session is disposed', async () => {
const session = Session.connectTo(defaultSession.model);
session.dispose();
const promise = session.setPath(UUID.uuid4());
await expectFailure(promise, 'Session is disposed');
});