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


TypeScript UnitTestTree.beginUpdate方法代碼示例

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


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

示例1: it

 it('should throw error if property is not found', () => {
   const content = JSON.stringify({});
   tree.create('tmp', content);
   const ast = parseJsonAst(content) as JsonAstObject;
   const recorder = tree.beginUpdate('tmp');
   expect(() => replacePropertyInAstObject(recorder, ast, 'foo', 'bar'))
       .toThrowError(`Property 'foo' does not exist in JSON object`);
 });
開發者ID:BobChao87,項目名稱:angular,代碼行數:8,代碼來源:json-utils_spec.ts

示例2: it

  it('should not fail when AppModule have imported RouterModule already', () => {
    const updateRecorder = appTree.beginUpdate('/projects/bar/src/app/app.module.ts');
    updateRecorder.insertLeft(0, 'import { RouterModule } from \'@angular/router\';');
    appTree.commitUpdate(updateRecorder);

    const tree = schematicRunner.runSchematic('appShell', defaultOptions, appTree);
    const filePath = '/projects/bar/src/app/app.module.ts';
    const content = tree.readContent(filePath);
    expect(content).toMatch(/import { RouterModule } from \'@angular\/router\';/);
  });
開發者ID:baconwaffles,項目名稱:angular-cli,代碼行數:10,代碼來源:index_spec.ts

示例3: runTest

  function runTest(testFn: Function, obj: JsonValue, indent: number): string {
    const content = JSON.stringify(obj, null, indent);
    tree.create(filePath, content);
    const ast = parseJsonAst(content);
    const rec = tree.beginUpdate(filePath);
    testFn(rec, ast);
    tree.commitUpdate(rec);

    const result = tree.readContent(filePath);
    // Clean up the tree by deleting the file.
    tree.delete(filePath);

    return result;
  }
開發者ID:angular,項目名稱:angular-cli,代碼行數:14,代碼來源:json-utils_spec.ts

示例4: runTest

    function runTest(obj: Pojso, prop: string, val: string): Pojso {
      const content = JSON.stringify(obj, null, 2);
      tree.create(filePath, content);
      const ast = parseJsonAst(content);
      const rec = tree.beginUpdate(filePath);
      if (ast.kind === 'object') {
        insertPropertyInAstObjectInOrder(rec, ast, prop, val, 2);
      }
      tree.commitUpdate(rec);

      const result = JSON.parse(tree.readContent(filePath));
      // Clean up the tree by deleting the file.
      tree.delete(filePath);

      return result;
    }
開發者ID:DevIntent,項目名稱:angular-cli,代碼行數:16,代碼來源:json-utils_spec.ts


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