From 3a43723618b923124ee43ab22aacfb9f1522d629 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 21 Mar 2018 16:33:03 +0100 Subject: [PATCH] tests/version-checks: Use `hasEmberVersion()` function see https://github.com/emberjs/ember-test-helpers/blob/v0.7.20/addon-test-support/%40ember/test-helpers/has-ember-version.js --- tests/dummy/app/version-checks.js | 34 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/dummy/app/version-checks.js b/tests/dummy/app/version-checks.js index 6bae6564..40e30225 100644 --- a/tests/dummy/app/version-checks.js +++ b/tests/dummy/app/version-checks.js @@ -2,22 +2,20 @@ import Ember from 'ember'; const { VERSION } = Ember; -const EMBERS_WITHOUT_POSITIONAL_PARAMS = [ - '1.12', - '1.11', -]; +export const hasPositionalParams = hasEmberVersion(1, 13); +export const hasReliablePositionalParams = hasEmberVersion(2, 3); -const EMBERS_WITHOUT_RELIABLE_POSITIONAL_PARAMS = [ - '2.2', - '2.1', - '2.0', - '1.13', - '1.12', - '1.11', -]; - -export const hasPositionalParams = !EMBERS_WITHOUT_POSITIONAL_PARAMS - .some(version => VERSION.indexOf(`${version}.`) === 0); - -export const hasReliablePositionalParams = !EMBERS_WITHOUT_RELIABLE_POSITIONAL_PARAMS - .some(version => VERSION.indexOf(`${version}.`) === 0); +/** + Checks if the currently running Ember version is greater than or equal to the + specified major and minor version numbers. + @private + @param {number} major the major version number to compare + @param {number} minor the minor version number to compare + @returns {boolean} true if the Ember version is >= MAJOR.MINOR specified, false otherwise +*/ +export function hasEmberVersion(major, minor) { + let numbers = VERSION.split('-')[0].split('.'); + let actualMajor = parseInt(numbers[0], 10); + let actualMinor = parseInt(numbers[1], 10); + return actualMajor > major || (actualMajor === major && actualMinor >= minor); +}