本文整理匯總了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');
});