• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript testing.UnitTestTree类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: describe

describe('Update 6.1.0', () => {
    let appTree: UnitTestTree;
    const schematicRunner = new SchematicTestRunner('ig-migrate', path.join(__dirname, '../migration-collection.json'));
    const configJson = {
        defaultProject: 'testProj',
        projects: {
            testProj: {
                sourceRoot: '/testSrc'
            }
        },
        schematics: {
            '@schematics/angular:component': {
                prefix: 'appPrefix'
            }
        }
      };

    beforeEach(() => {
        appTree = new UnitTestTree(new EmptyTree());
        appTree.create('/angular.json', JSON.stringify(configJson));
    });

    it('should update igxToggle events and selectors', done => {
        appTree.create(
            '/testSrc/appPrefix/component/test.component.html',
            `<igx-tab-bar attr igxForRemote="true"></igx-tab-bar>` +
            `<elem igxToggle (onOpen)="handler" (onClose)="handler"></elem>`
        );
        const tree = schematicRunner.runSchematic('migration-04', {}, appTree);
        expect(tree.readContent('/testSrc/appPrefix/component/test.component.html'))
            .toEqual(
                `<igx-bottom-nav attr></igx-bottom-nav>` +
                `<elem igxToggle (onOpened)="handler" (onClosed)="handler"></elem>`);
        done();
    });
});
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:36,代码来源:index.spec.ts


示例2: describe

  describe('SASS', () => {
    let host = new UnitTestTree(new HostTree);
    beforeAll(() => {
      host.create('/src/app/app.component.scss', '');
      expect(host.files).toContain('/src/app/app.component.scss');
      const options = {...defaultOptions};
      host = schematicRunner.runSchematic('bazel-workspace', options, host);
      expect(host.files).toContain('/WORKSPACE');
      expect(host.files).toContain('/src/BUILD.bazel');
    });

    it('should download and load rules_sass in WORKSPACE', () => {
      const content = host.readContent('/WORKSPACE');
      expect(content).toContain('RULES_SASS_VERSION');
      expect(content).toContain(
          'load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")');
    });

    it('should add sass_binary rules in src/BUILD', () => {
      const content = host.readContent('/src/BUILD.bazel');
      expect(content).toContain('load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")');
      expect(content).toContain('glob(["**/*.scss"])');
    });
  });
开发者ID:matsko,项目名称:angular,代码行数:24,代码来源:index_spec.ts


示例3: myProp

    it('should detect static queries used through external getter access', () => {
      writeFile('/index.ts', `
        import {Component, ${queryType}} from '@angular/core';
        import {External} from './external';
                        
        @Component({template: '<span #test></span>'})
        export class MyComp {
          @${queryType}('test') query: any;
          
          private external = new External(this);
                
          get myProp() {
            return this.query.myValue;
          }
          
          ngOnInit() {
            console.log(this.external.query);
          }
        }
      `);

      writeFile('/external.ts', `
        import {MyComp} from './index';
      
        export class External {
          constructor(private comp: MyComp) {}
          
          get query() { return this.comp.query; }
        }
      `);

      runMigration();

      expect(tree.readContent('/index.ts'))
          .toContain(`@${queryType}('test', { static: true }) query: any;`);
    });
开发者ID:StephenFluin,项目名称:angular,代码行数:36,代码来源:static_queries_migration_spec.ts


示例4: it

    it('should update Sass files', done => {
        appTree.create(
            '/testSrc/appPrefix/style.scss',
`$dark-chip-theme: igx-chip-theme(
    $roundness: 4px,
    $chip-background: #180505,
    $chip-hover-background: white,
    $remove-icon-color: red,
    $dir-icon-color: yellow,
    $selected-chip-hover-background: gray
);`
        );
        const tree = schematicRunner.runSchematic('migration-06', {}, appTree);
        expect(tree.readContent('/testSrc/appPrefix/style.scss'))
            .toEqual(
`$dark-chip-theme: igx-chip-theme(
    $roundness: 4px,
    $background: #180505,
    $hover-background: white,
    $hover-selected-background: gray
);`
            );
        done();
    });
开发者ID:IgniteUI,项目名称:igniteui-angular,代码行数:24,代码来源:index.spec.ts


示例5: runMigration

    it('should detect inherited queries', async() => {
      writeFile('/index.ts', `
        import {Component, NgModule, ViewChild} from '@angular/core';
        
        export class BaseClass {
          @ViewChild('myRef') query: any;
        }
                        
        @Component({templateUrl: 'my-tmpl.html'})
        export class MyComp extends BaseClass {}
        
        @NgModule({declarations: [MyComp]})
        export class MyModule {}
      `);

      writeFile(`/my-tmpl.html`, `
          <span #myRef>My Ref</span>
      `);

      await runMigration();

      expect(tree.readContent('/index.ts'))
          .toContain(`@ViewChild('myRef', { static: true }) query: any;`);
    });
开发者ID:alxhub,项目名称:angular,代码行数:24,代码来源:static_queries_migration_template_spec.ts


示例6: myProperty

    it('should detect input decorator on setter', async() => {
      writeFile('/index.ts', `
        import {Input, Component, ${queryType}} from '@angular/core';
        
        @Component({template: '<span #test></span>'})
        export class MyComp {
          @${queryType}('test') query: any;
          
          get myProperty() { return null; }
          
          // Usually the decorator is set on the get accessor, but it's also possible
          // to declare the input on the setter. This ensures that it is handled properly.
          @Input()
          set myProperty(val: any) {
            this.query.test();
          }
        }
      `);

      await runMigration();

      expect(tree.readContent('/index.ts'))
          .toContain(`@${queryType}('test', { static: true }) query: any;`);
    });
开发者ID:alxhub,项目名称:angular,代码行数:24,代码来源:static_queries_migration_usage_spec.ts


示例7: runMigration

    it('should add a todo if query options cannot be migrated inline', async() => {
      writeFile('/index.ts', `
        import {Component, NgModule, ViewChild} from '@angular/core';
        
        const myOptionsVar = {};

        @Component({template: '<p #myRef></p>'})
        export class MyComp {
          @ViewChild('myRef', myOptionsVar) query: any;
        }

        @NgModule({declarations: [MyComp]})
        export class MyModule {}
      `);

      await runMigration();

      expect(tree.readContent('/index.ts'))
          .toContain(`@ViewChild('myRef', /* TODO: add static flag */ myOptionsVar) query: any;`);
      expect(warnOutput.length).toBe(1);
      expect(warnOutput[0])
          .toMatch(/^⮑ {3}index.ts@8:11: Cannot update query declaration to explicit timing./);
      expect(warnOutput[0]).toMatch(/Please manually set the query timing to.*static: true/);
    });
开发者ID:marclaval,项目名称:angular,代码行数:24,代码来源:static_queries_migration_template_spec.ts


示例8: myProp

    it('should not mark queries as static if a value is assigned to accessor property', async() => {
      writeFile('/index.ts', `
        import {Component, ${queryType}} from '@angular/core';
                        
        @Component({template: '<span #test></span>'})
        export class MyComp {
          private @${queryType}('test') query: any;
              
          set myProp(value: any) { /* noop */}
          get myProp() {
            return this.query.myValue;
          }
          
          ngOnInit() {
            this.myProp = true;
          }
        }
      `);

      await runMigration();

      expect(tree.readContent('/index.ts'))
          .toContain(`@${queryType}('test', { static: false }) query: any;`);
    });
开发者ID:alxhub,项目名称:angular,代码行数:24,代码来源:static_queries_migration_usage_spec.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript tools.NodeModulesEngineHost类代码示例发布时间:2022-05-28
下一篇:
TypeScript testing.SchematicTestRunner类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap