當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript coreutils.UUID類代碼示例

本文整理匯總了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;
    });
開發者ID:willingc,項目名稱:jupyterlab,代碼行數:22,代碼來源:ikernel.spec.ts

示例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);
 });
開發者ID:alexmorley,項目名稱:jupyterlab,代碼行數:22,代碼來源:context.spec.ts

示例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();
    });
開發者ID:afshin,項目名稱:jupyterlab,代碼行數:36,代碼來源:ikernel.spec.ts

示例4: beforeAll

 beforeAll(async () => {
   session = await Session.startNew({ path: UUID.uuid4() });
   await session.kernel.ready;
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:4,代碼來源:manager.spec.ts

示例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();
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:6,代碼來源:manager.spec.ts

示例6: startNew

/**
 * Start a new session with a unique name.
 */
function startNew(): Promise<Session.ISession> {
  return Session.startNew({ path: UUID.uuid4() });
}
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:6,代碼來源:session.spec.ts

示例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;
 });
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:6,代碼來源:session.spec.ts

示例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');
 });
開發者ID:willingc,項目名稱:jupyterlab,代碼行數:6,代碼來源:session.spec.ts


注:本文中的@phosphor/coreutils.UUID類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。