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


TypeScript UnitTestTree.overwrite方法代码示例

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


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

示例1: it

  it('should work as expected for a project with a root', async () => {
    const originalContent = JSON.parse(tree.readContent('angular.json'));
    originalContent.projects['migration-test'].root = 'src';
    tree.overwrite('angular.json', JSON.stringify(originalContent));
    const polyfillPath = '/src/polyfills.ts';
    tree.overwrite(polyfillPath, oldPolyfills);
    const tree2 = await schematicRunner.runSchematicAsync('migration-03', {}, tree.branch())
      .toPromise();

    expect(tree2.readContent(polyfillPath)).not.toMatch(/import .*es7.*reflect.*;/);
  });
开发者ID:DevIntent,项目名称:angular-cli,代码行数:11,代码来源:polyfill-metadata_spec.ts

示例2: it

  it('should enable web-anmations and object.entries properly on projects with ng cli version >= 7.3', () => {
    const polyfills = `
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js';  // Run \`npm install --save classlist.js\`.

// import 'web-animations-js';  // Run \`npm install --save web-animations-js\`.
    `;

    const result = `
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js';  // Run \`npm install --save classlist.js\`.

/** ES7 \`Object.entries\` needed for igxGrid to render in IE. */
import 'core-js/es7/object';

import 'web-animations-js';  // Run \`npm install --save web-animations-js\`.
    `;

    tree.create('src/polyfills.ts', polyfills);
    const newJson: any = JSON.parse(tree.read('/angular.json').toString());
    newJson.projects['testProj'].architect.build.options['es5BrowserSupport'] = false;
    tree.overwrite('/angular.json', JSON.stringify(newJson));
    runner.runSchematic('ng-add', { polyfills: true }, tree);
    expect(tree.readContent('src/polyfills.ts').replace(/\r\n/g, '\n')).toEqual(result.replace(/\r\n/g, '\n'));
  });
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:25,代码来源:index.spec.ts

示例3: it

  it('should wrap the bootstrap decleration in a DOMContentLoaded event handler', () => {
    const filePath = '/projects/bar/src/main.ts';
    appTree.overwrite(
      filePath,
      `
      import { enableProdMode } from '@angular/core';
      import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
      import { AppModule } from './app/app.module';
      import { environment } from './environments/environment';
      import { hmrBootstrap } from './hmr';

      if (environment.production) {
        enableProdMode();
      }

      const bootstrap = () => platformBrowserDynamic().bootstrapModule(AppModule);

      if (!hmrBootstrap) {
        bootstrap().catch(err => console.log(err));
      }
      `,
    );

    const tree = schematicRunner.runSchematic('universal', defaultOptions, appTree);
    const contents = tree.readContent(filePath);
    expect(contents).toMatch(
      /document.addEventListener\('DOMContentLoaded', \(\) => {[\n\r\s]+bootstrap\(\)/,
    );
  });
开发者ID:ankitrawal001,项目名称:angular-cli,代码行数:29,代码来源:index_spec.ts

示例4: it

 it('should update theme import in sass files', done => {
     const config = JSON.parse(JSON.stringify(configJson));
     config.projects.testProj['schematics'] = {
         '@schematics/angular:component': {
             styleext: 'sass'
         }
     };
     appTree.overwrite('/angular.json', JSON.stringify(config));
     appTree.create(
         '/testSrc/appPrefix/component/test.component.sass',
         `@import "~igniteui-angular/core/styles/themes/index";`
     );
     appTree.create(
         '/testSrc/testSrc/styles.sass',
         `@import "~igniteui-angular/core/styles/themes/_index.scss";`
     );
     const tree = schematicRunner.runSchematic('migration-03', {}, appTree);
     expect(tree.readContent('/testSrc/appPrefix/component/test.component.sass')).toEqual(
         `@import "~igniteui-angular/lib/core/styles/themes/index";`
     );
     expect(tree.readContent('/testSrc/testSrc/styles.sass')).toEqual(
         `@import "~igniteui-angular/lib/core/styles/themes/_index.scss";`
     );
     done();
 });
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:25,代码来源:index.spec.ts

示例5: it

 it('should respect the sourceRoot value', () => {
   const config = JSON.parse(appTree.readContent('/angular.json'));
   config.projects.bar.sourceRoot = 'projects/bar/custom';
   appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
   appTree = schematicRunner.runSchematic('class', defaultOptions, appTree);
   expect(appTree.files.indexOf('/projects/bar/custom/app/foo.ts')).toBeGreaterThanOrEqual(0);
 });
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:7,代码来源:index_spec.ts

示例6: it

 it('should respect the sourceRoot value', () => {
   const config = JSON.parse(appTree.readContent('/angular.json'));
   config.projects.bar.sourceRoot = 'projects/bar/custom';
   appTree.overwrite('/angular.json', JSON.stringify(config, null, 2));
   appTree = schematicRunner.runSchematic('service', defaultOptions, appTree);
   expect(appTree.files).toContain('/projects/bar/custom/app/foo/foo.service.ts');
 });
开发者ID:DevIntent,项目名称:angular-cli,代码行数:7,代码来源:index_spec.ts

示例7: makeInlineTemplate

    function makeInlineTemplate(tree: UnitTestTree, template?: string): void {
      template = template || `
      <p>
        App works!
      </p>`;
      const newText = `
        import { Component, OnInit } from '@angular/core';

        @Component({
          selector: ''
          template: \`
            ${template}
          \`,
          styleUrls: ['./app.component.css']
        })
        export class AppComponent implements OnInit {

          constructor() { }

          ngOnInit() {
          }

        }

      `;
      tree.overwrite('/projects/bar/src/app/app.component.ts', newText);
      tree.delete('/projects/bar/src/app/app.component.html');
    }
开发者ID:baconwaffles,项目名称:angular-cli,代码行数:28,代码来源:index_spec.ts

示例8: it

 it('should add a dev dependency to @angular-devkit/build-angular (no dev)', () => {
   tree.create(oldConfigPath, JSON.stringify(baseConfig, null, 2));
   tree.overwrite('/package.json', JSON.stringify({}, null, 2));
   tree = schematicRunner.runSchematic('migration-01', defaultOptions, tree);
   const content = tree.readContent('/package.json');
   const pkg = JSON.parse(content);
   expect(pkg.devDependencies['@angular-devkit/build-angular'])
     .toBe(latestVersions.DevkitBuildAngular);
 });
开发者ID:iwe7,项目名称:devkit,代码行数:9,代码来源:index_spec.ts


注:本文中的@angular-devkit/schematics/testing.UnitTestTree.overwrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。