当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript UnitTestTree.commitUpdate方法代码示例

本文整理汇总了TypeScript中@angular-devkit/schematics/testing.UnitTestTree.commitUpdate方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UnitTestTree.commitUpdate方法的具体用法?TypeScript UnitTestTree.commitUpdate怎么用?TypeScript UnitTestTree.commitUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular-devkit/schematics/testing.UnitTestTree的用法示例。


在下文中一共展示了UnitTestTree.commitUpdate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: 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

示例2: it

 it('should be a noop if key is not found', () => {
   const content = JSON.stringify({foo: 'bar'});
   tree.create('tmp', content);
   const ast = parseJsonAst(content) as JsonAstObject;
   let recorder = tree.beginUpdate('tmp');
   expect(() => removeKeyValueInAstObject(recorder, content, ast, 'hello')).not.toThrow();
   tree.commitUpdate(recorder);
   const value = tree.readContent('tmp');
   expect(JSON.parse(value)).toEqual({foo: 'bar'});
   expect(value).toBe('{"foo":"bar"}');
 });
开发者ID:BobChao87,项目名称:angular,代码行数:11,代码来源:json-utils_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.commitUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。