本文整理汇总了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);
});
}));
});
});
示例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"`);
});
});
示例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');
});
});
示例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', () => {