本文整理匯總了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');
});
});
示例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');
});
示例3:
() => generator.getImportPath('http:somePkg/lib/modPath', 'asset:somePkg/test/impPath'))