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

TypeScript testing.onlyInIvy函数代码示例

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

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



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

示例1: describe

describe('SystemJsNgModuleLoader', () => {
  let oldSystem: any = null;
  modifiedInIvy('only loads ngfactory shims in View Engine').describe('(View Engine)', () => {
    beforeEach(() => {
      oldSystem = global['System'];
      global['System'] = mockSystem({
        'test.ngfactory':
            {'default': 'test module factory', 'NamedNgFactory': 'test NamedNgFactory'},
        'prefixed/test/suffixed': {'NamedNgFactory': 'test module factory'}
      });
    });
    afterEach(() => { global['System'] = oldSystem; });

    it('loads a default factory by appending the factory suffix', async(() => {
         const loader = new SystemJsNgModuleLoader(new Compiler());
         loader.load('test').then(
             contents => { expect(contents).toBe('test module factory' as any); });
       }));
    it('loads a named factory by appending the factory suffix', async(() => {
         const loader = new SystemJsNgModuleLoader(new Compiler());
         loader.load('test#Named').then(contents => {
           expect(contents).toBe('test NamedNgFactory' as any);
         });
       }));
    it('loads a named factory with a configured prefix and suffix', async(() => {
         const loader = new SystemJsNgModuleLoader(new Compiler(), {
           factoryPathPrefix: 'prefixed/',
           factoryPathSuffix: '/suffixed',
         });
         loader.load('test#Named').then(contents => {
           expect(contents).toBe('test module factory' as any);
         });
       }));
  });

  onlyInIvy('loads modules directly in Ivy').describe('(Ivy)', () => {
    beforeEach(() => {
      oldSystem = global['System'];
      global['System'] = mockSystem({
        'test': {'default': 'test module', 'NamedModule': 'test NamedModule'},
      });
    });
    afterEach(() => { global['System'] = oldSystem; });

    it('loads a default module', async(() => {
         const loader = new SystemJsNgModuleLoader(new Compiler());
         loader.load('test').then(
             contents => { expect(contents.moduleType).toBe('test module' as any); });
       }));
    it('loads a named module', async(() => {
         const loader = new SystemJsNgModuleLoader(new Compiler());
         loader.load('test#NamedModule').then(contents => {
           expect(contents.moduleType).toBe('test NamedModule' as any);
         });
       }));
  });
});
开发者ID:Cammisuli,项目名称:angular,代码行数:57,代码来源:system_ng_module_factory_loader_spec.ts


示例2: describe

  describe('flat module out file', () => {

    obsoleteInIvy('Ngtsc computes the AMD module name differently than NGC')
        .it('should have a proper AMD module name', () => {
          expect(readFileSync(flatModuleOutFile, 'utf8'))
              .toContain(`define("flat_module/flat_module"`);
        });

    onlyInIvy('Ngtsc computes the AMD module name differently than NGC')
        .it('should have a proper AMD module name', () => {
          expect(readFileSync(flatModuleOutFile, 'utf8')).toContain(`define("flat_module"`);
        });
  });
开发者ID:BobChao87,项目名称:angular,代码行数:13,代码来源:flat_module_test.ts


示例3: describe

  describe('move', () => {
    onlyInIvy('Ivy will insert detached views in move')
        .it('should insert detached views in move()', () => {
          const fixture = TestBed.createComponent(ViewContainerRefApp);
          fixture.detectChanges();

          const templates = fixture.componentInstance.vcrComp.templates.toArray();
          const viewContainerRef = fixture.componentInstance.vcrComp.vcr;
          const ref0 = viewContainerRef.createEmbeddedView(templates[0]);
          const ref1 = viewContainerRef.createEmbeddedView(templates[1]);
          const ref2 = viewContainerRef.createEmbeddedView(templates[2]);

          viewContainerRef.detach(0);
          viewContainerRef.move(ref0, 0);

          expect(fixture.nativeElement.textContent).toEqual('012');
        });
  });
开发者ID:StephenFluin,项目名称:angular,代码行数:18,代码来源:view_container_ref_spec.ts


示例4: describe


//.........这里部分代码省略.........

      TestBed.configureTestingModule({declarations: [App, MyComponent]});
      const fixture = TestBed.createComponent(App);
      fixture.detectChanges();
      fixture.destroy();

      expect(logs).toEqual(['OnDestroy']);
    });

    it('should call ngOnDestroy when providing same token via useClass', () => {
      const logs: string[] = [];

      @Injectable()
      class InjectableWithDestroyHook {
        ngOnDestroy() { logs.push('OnDestroy'); }
      }

      @Component({
        template: '',
        providers: [{provide: InjectableWithDestroyHook, useClass: InjectableWithDestroyHook}]
      })
      class App {
        constructor(foo: InjectableWithDestroyHook) {}
      }

      TestBed.configureTestingModule({declarations: [App]});
      const fixture = TestBed.createComponent(App);
      fixture.detectChanges();
      fixture.destroy();

      expect(logs).toEqual(['OnDestroy']);
    });

    onlyInIvy('Destroy hook of useClass provider is invoked correctly')
        .it('should only call ngOnDestroy of value when providing via useClass', () => {
          const logs: string[] = [];

          @Injectable()
          class InjectableWithDestroyHookToken {
            ngOnDestroy() { logs.push('OnDestroy Token'); }
          }

          @Injectable()
          class InjectableWithDestroyHookValue {
            ngOnDestroy() { logs.push('OnDestroy Value'); }
          }

          @Component({
            template: '',
            providers: [
              {provide: InjectableWithDestroyHookToken, useClass: InjectableWithDestroyHookValue}
            ]
          })
          class App {
            constructor(foo: InjectableWithDestroyHookToken) {}
          }

          TestBed.configureTestingModule({declarations: [App]});
          const fixture = TestBed.createComponent(App);
          fixture.detectChanges();
          fixture.destroy();

          expect(logs).toEqual(['OnDestroy Value']);
        });

    it('should only call ngOnDestroy of value when providing via useExisting', () => {
开发者ID:Cammisuli,项目名称:angular,代码行数:67,代码来源:providers_spec.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript testing.withBody函数代码示例发布时间:2022-05-28
下一篇:
TypeScript testing.obsoleteInIvy函数代码示例发布时间: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