当前位置: 首页>>代码示例>>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;未经允许,请勿转载。