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


TypeScript schematics.HostSink類代碼示例

本文整理匯總了TypeScript中@angular-devkit/schematics.HostSink的典型用法代碼示例。如果您正苦於以下問題:TypeScript HostSink類的具體用法?TypeScript HostSink怎麽用?TypeScript HostSink使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HostSink類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('works', done => {
    const host = new virtualFs.test.TestHost({
      '/hello': 'world',
      '/sub/directory/file2': '',
      '/sub/file1': '',
    });
    const tree = new HostCreateTree(host);

    tree.create('/test', 'testing 1 2');
    const recorder = tree.beginUpdate('/test');
    recorder.insertLeft(8, 'testing ');
    tree.commitUpdate(recorder);

    const files = ['/hello', '/sub/directory/file2', '/sub/file1', '/test'];
    const treeFiles: string[] = [];
    tree.visit(path => treeFiles.push(path));
    treeFiles.sort();
    expect(treeFiles).toEqual(files);

    const outputHost = new virtualFs.test.TestHost();
    const sink = new HostSink(outputHost);
    sink.commit(optimize(tree))
        .toPromise()
        .then(() => {
          const tmpFiles = outputHost.files.sort();
          expect(tmpFiles as string[]).toEqual(files);
          expect(outputHost.sync.read(normalize('/test')).toString())
            .toBe('testing testing 1 2');
        })
        .then(done, done.fail);
  });
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:31,代碼來源:host_spec.ts

示例2: beforeEach

    beforeEach(done => {
      // Commit a version of the tree.
      const host = new virtualFs.test.TestHost({
        '/file0': '/file0',
        '/sub/directory/file2': '/sub/directory/file2',
        '/sub/file1': '/sub/file1',
      });
      const tree = new HostCreateTree(host);

      const outputHost = new virtualFs.test.TestHost();
      const sink = new HostSink(outputHost);
      sink.commit(optimize(tree))
          .toPromise()
          .then(done, done.fail);
    });
開發者ID:rexebin,項目名稱:angular-cli,代碼行數:15,代碼來源:host_spec.ts

示例3: it

    it('can rename files', done => {
      const host = new virtualFs.test.TestHost({
        '/file0': '/file0',
      });
      const tree = new FileSystemTree(host);
      tree.rename('/file0', '/file1');

      const sink = new HostSink(host);
      sink.commit(optimize(tree))
          .toPromise()
          .then(() => {
            expect(host.sync.exists(normalize('/file0'))).toBe(false);
            expect(host.sync.exists(normalize('/file1'))).toBe(true);
          })
          .then(done, done.fail);
    });
開發者ID:fmalcher,項目名稱:angular-cli,代碼行數:16,代碼來源:host_spec.ts


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