How to use the ember-window-mock.navigator 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 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
  };
}
github gokatz / ember-device / addon / lib / save-data.js View on Github external
export default function getSaveDataStatus() {
  let unsupported;
  if ('connection' in window.navigator && 'saveData' in window.navigator.connection) {
    unsupported = false;
  } else {
    unsupported = true;
  }

  const isEnabled = unsupported ? null : window.navigator.connection.saveData === true;

  return { unsupported, isEnabled }
}

ember-window-mock

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

MIT
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis