How to use the ember-window-mock.location function in ember-window-mock

To help you get started, we’ve selected a few ember-window-mock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirego / ember-boilerplate / app / services / app-url / builder.ts View on Github external
build(path: string = '/'): string {
    if (!this.fastboot.isFastBoot) {
      return `${window.location.protocol}//${window.location.host}${path}`;
    }

    const request = this.fastboot.request;

    // NOTE: On Heroku, `request.get('protocol')` returns `"http:"`
    // even if it’s an HTTPS request, so we can’t use it.
    const protocol = config.APP.FORCE_SSL ? 'https:' : 'http:';

    return `${protocol}//${request.host}${path}`;
  }
}
github thoov / ember-redirect / addon / utils / reopen-route.js View on Github external
beforeModel(transition) {
      let newDynObject       = {};
      let thisRouteName      = this.routeName;
      let routeNames         = this.router._routerMicrolib.recognizer.names;
      let dynSegsOfNextRoute = null;
      let dynSegsOfThisRoute = null;

      // If the redirect route is not a valid route name in this app AND then redirect
      // looks like a url, send um that-a-way via location.replace
      if (!routeNames[options.redirect] && resemblesURL(options.redirect)) {
        transition.abort();
        window.location.assign(options.redirect);
        return false;
      }

      dynSegsOfNextRoute = getDynamicSegments(routeNames[options.redirect].segments);
      dynSegsOfThisRoute = getDynamicSegments(routeNames[thisRouteName].segments);

      // Make sure we only try to make a redirect at the most nested
      // route and not a parent resource.
      if(this.routeName !== transition.targetName) {
        return false;
      }

      // Make sure that the lengths are the same else we are trying to transition to a route that needs more
      // segments then we can supply.
      if(dynSegsOfNextRoute.length <= dynSegsOfThisRoute.length) {
github mirego / ember-boilerplate / app / services / location.ts View on Github external
assign(location: string): void {
    window.location.href = location;
  }
}
github travis-ci / travis-web / app / components / owner / repositories.js View on Github external
sort_by: 'name',
      'repository.managed_by_installation': false,
      'repository.active': true,
      custom: {
        owner: this.owner.login,
        type: 'byOwner',
      },
    };

    let repositories = yield this.store.paginated('repo', queryParams, { live: false }) || [];

    yield fetchAll(this.store, 'repo', queryParams);

    let githubQueryParams = repositories.map(repo => `repository_ids[]=${repo.githubId}`).join('&');

    window.location.href =
      `https://github.com/apps/${appName}/installations/new/permissions` +
      `?suggested_target_id=${this.owner.githubId}&${githubQueryParams}`;
  })
});

ember-window-mock

Wraps the global window object with a proxy that can be mocked in tests

MIT
Latest version published 3 months ago

Package Health Score

81 / 100
Full package analysis