How to use ember-window-mock - 10 common examples

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 peopleconnectus / ember-concurrency-scroll / addon / services / scroller.js View on Github external
let end;
    // if we're targeting a container, account for offset to start and end
    if (options.container) {
      end = {
        y: element.offsetTop,
        x: element.offsetLeft
      };
      let container = this.getContainer(options.container);
      start.y = container.scrollTop;
      end.y = end.y - container.offsetTop;
      start.x = container.scrollLeft;
      end.x = end.x - container.offsetLeft;
    } else {
      end = {
        y: window.pageYOffset + element.getBoundingClientRect().top,
        x: window.pageXOffset + element.getBoundingClientRect().left
      };
    }
    yield this.get('scrollToTask').perform(start, end, options);
  }),
github peopleconnectus / ember-concurrency-scroll / addon / services / scroller.js View on Github external
};
    let end;
    // if we're targeting a container, account for offset to start and end
    if (options.container) {
      end = {
        y: element.offsetTop,
        x: element.offsetLeft
      };
      let container = this.getContainer(options.container);
      start.y = container.scrollTop;
      end.y = end.y - container.offsetTop;
      start.x = container.scrollLeft;
      end.x = end.x - container.offsetLeft;
    } else {
      end = {
        y: window.pageYOffset + element.getBoundingClientRect().top,
        x: window.pageXOffset + element.getBoundingClientRect().left
      };
    }
    yield this.get('scrollToTask').perform(start, end, options);
  }),
github kaliber5 / ember-window-mock / tests / dummy / app / components / window-tester.js View on Github external
init() {
    this._super(...arguments);

    this.set('counter', +window.localStorage.getItem('counter') || 1);
  },
github kaliber5 / ember-window-mock / tests / dummy / app / components / window-tester.js View on Github external
increment() {
      this.incrementProperty('counter');
      window.localStorage.setItem('counter', this.get('counter'));
    }
  }
github gokatz / ember-device / addon / lib / hardware-concurrency.js View on Github external
export default function getHardwareConcurrency() {
  let initialHardwareConcurrency;
  if (typeof window.navigator !== 'undefined' && 'hardwareConcurrency' in window.navigator) {
    initialHardwareConcurrency = { numberOfLogicalProcessors: window.navigator.hardwareConcurrency };
  } else {
    initialHardwareConcurrency = { unsupported: true };
  }
  return initialHardwareConcurrency;  
}
github gokatz / ember-device / addon / lib / memory.js View on Github external
export default function getMemoryStatus() {
  let unsupported;
  if (typeof window.navigator !== 'undefined' && 'deviceMemory' in window.navigator) {
    unsupported = false;
  } else {
    unsupported = true;
  }
  let initialMemoryStatus;
  if (!unsupported) {
    const performanceMemory = 'memory' in window.performance ? window.performance.memory : null;
    initialMemoryStatus = {
      deviceMemory: window.navigator.deviceMemory,
      totalJSHeapSize: performanceMemory ? performanceMemory.totalJSHeapSize : null,
      usedJSHeapSize: performanceMemory ? performanceMemory.usedJSHeapSize : null,
      jsHeapSizeLimit: performanceMemory ? performanceMemory.jsHeapSizeLimit : null
    };
  } else {
    initialMemoryStatus = { unsupported };
  }
github gokatz / ember-device / addon / lib / network.js View on Github external
export default function getNetworkStatus() {
  if ('connection' in window.navigator && 'effectiveType' in window.navigator.connection) {
    unsupported = false;
  } else {
    unsupported = true;
  }

  return !unsupported ? {
    effectiveConnectionType: window.navigator.connection.effectiveType
  } : {
    unsupported
  };
}

ember-window-mock

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

MIT
Latest version published 4 months ago

Package Health Score

74 / 100
Full package analysis