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


TypeScript testing.onlyInIvy函数代码示例

本文整理汇总了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;未经允许,请勿转载。