本文整理汇总了TypeScript中@angular/compiler/src/output/dart_imports.DartImportGenerator类的典型用法代码示例。如果您正苦于以下问题:TypeScript DartImportGenerator类的具体用法?TypeScript DartImportGenerator怎么用?TypeScript DartImportGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DartImportGenerator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('getImportPath', () => {
var generator: DartImportGenerator;
beforeEach(() => { generator = new DartImportGenerator(); });
it('should calculate relative paths Dart', () => {
expect(generator.getImportPath('asset:somePkg/lib/modPath', 'asset:somePkg/lib/impPath'))
.toEqual('impPath');
});
it('should calculate relative paths for different constellations', () => {
expect(generator.getImportPath('asset:somePkg/test/modPath', 'asset:somePkg/test/impPath'))
.toEqual('impPath');
expect(
generator.getImportPath('asset:somePkg/lib/modPath', 'asset:somePkg/lib/dir2/impPath'))
.toEqual('dir2/impPath');
expect(
generator.getImportPath('asset:somePkg/lib/dir1/modPath', 'asset:somePkg/lib/impPath'))
.toEqual('../impPath');
expect(generator.getImportPath(
'asset:somePkg/lib/dir1/modPath', 'asset:somePkg/lib/dir2/impPath'))
.toEqual('../dir2/impPath');
});
it('should calculate absolute paths', () => {
expect(
generator.getImportPath('asset:somePkg/lib/modPath', 'asset:someOtherPkg/lib/impPath'))
.toEqual('package:someOtherPkg/impPath');
});
it('should not allow absolute imports of non lib modules', () => {
expect(
() =>
generator.getImportPath('asset:somePkg/lib/modPath', 'asset:somePkg/test/impPath'))
.toThrowError(
`Can't import url asset:somePkg/test/impPath from asset:somePkg/lib/modPath`);
});
it('should not allow non asset urls as base url', () => {
expect(
() => generator.getImportPath('http:somePkg/lib/modPath', 'asset:somePkg/test/impPath'))
.toThrowError(`Url http:somePkg/lib/modPath is not a valid asset: url`);
});
it('should allow non asset urls as import urls and pass them through', () => {
expect(generator.getImportPath('asset:somePkg/lib/modPath', 'dart:html'))
.toEqual('dart:html');
});
});
开发者ID:BharatBhatiya,项目名称:test,代码行数:48,代码来源:dart_imports_spec.ts
示例2: it
it('should calculate relative paths for different constellations', () => {
expect(generator.getImportPath('asset:somePkg/test/modPath', 'asset:somePkg/test/impPath'))
.toEqual('impPath');
expect(
generator.getImportPath('asset:somePkg/lib/modPath', 'asset:somePkg/lib/dir2/impPath'))
.toEqual('dir2/impPath');
expect(
generator.getImportPath('asset:somePkg/lib/dir1/modPath', 'asset:somePkg/lib/impPath'))
.toEqual('../impPath');
expect(generator.getImportPath('asset:somePkg/lib/dir1/modPath',
'asset:somePkg/lib/dir2/impPath'))
.toEqual('../dir2/impPath');
});
开发者ID:0xJoKe,项目名称:angular,代码行数:13,代码来源:dart_imports_spec.ts
示例3:
() => generator.getImportPath('http:somePkg/lib/modPath', 'asset:somePkg/test/impPath'))
开发者ID:0xJoKe,项目名称:angular,代码行数:1,代码来源:dart_imports_spec.ts
注:本文中的@angular/compiler/src/output/dart_imports.DartImportGenerator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论