當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dart_imports.DartImportGenerator類代碼示例

本文整理匯總了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;未經允許,請勿轉載。