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


TypeScript upgrade.setUpLocationSync函數代碼示例

本文整理匯總了TypeScript中@angular/router/upgrade.setUpLocationSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript setUpLocationSync函數的具體用法?TypeScript setUpLocationSync怎麽用?TypeScript setUpLocationSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了setUpLocationSync函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: setUpLocationSync

     () => {
       const $rootScope = jasmine.createSpyObj('$rootScope', ['$on']);

       upgradeModule.$injector.get.and.callFake(
           (name: string) => (name === '$rootScope') && $rootScope);

       setUpLocationSync(upgradeModule);

       expect($rootScope.$on).toHaveBeenCalledTimes(1);
       expect($rootScope.$on).toHaveBeenCalledWith('$locationChangeStart', jasmine.any(Function));
     });
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:11,代碼來源:upgrade.spec.ts

示例2: it

  it('should work correctly on browsers that do not start pathname with `/`', () => {
    const anchorProto = HTMLAnchorElement.prototype;
    const originalDescriptor = Object.getOwnPropertyDescriptor(anchorProto, 'pathname');
    Object.defineProperty(anchorProto, 'pathname', {get: () => 'foo/bar'});

    try {
      const $rootScope = jasmine.createSpyObj('$rootScope', ['$on']);
      upgradeModule.$injector.get.and.returnValue($rootScope);

      setUpLocationSync(upgradeModule);

      const callback = $rootScope.$on.calls.argsFor(0)[1];
      callback({}, '', '');

      expect(LocationMock.normalize).toHaveBeenCalledWith('/foo/bar');
    } finally {
      Object.defineProperty(anchorProto, 'pathname', originalDescriptor !);
    }
  });
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:19,代碼來源:upgrade.spec.ts

示例3: it

  it('should allow configuration to work with hash-based routing', () => {
    const url = 'https://google.com';
    const pathname = '/custom/route';
    const normalizedPathname = 'foo';
    const query = '?query=1&query2=3';
    const hash = '#new/hash';
    const combinedUrl = url + '#' + pathname + query + hash;
    const $rootScope = jasmine.createSpyObj('$rootScope', ['$on']);

    upgradeModule.$injector.get.and.returnValue($rootScope);
    LocationMock.normalize.and.returnValue(normalizedPathname);

    setUpLocationSync(upgradeModule, 'hash');

    const callback = $rootScope.$on.calls.argsFor(0)[1];
    callback({}, combinedUrl, '');

    expect(LocationMock.normalize).toHaveBeenCalledTimes(1);
    expect(LocationMock.normalize).toHaveBeenCalledWith(pathname);

    expect(RouterMock.navigateByUrl).toHaveBeenCalledTimes(1);
    expect(RouterMock.navigateByUrl).toHaveBeenCalledWith(normalizedPathname + query + hash);
  });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:23,代碼來源:upgrade.spec.ts

示例4: expect

 expect(() => setUpLocationSync(upgradeModule)).toThrowError(`
開發者ID:DeepanParikh,項目名稱:angular,代碼行數:1,代碼來源:upgrade.spec.ts


注:本文中的@angular/router/upgrade.setUpLocationSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。