Skip to content

Commit

Permalink
tests/version-checks: Use hasEmberVersion() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Mar 21, 2018
1 parent 1e5701a commit 3a43723
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions tests/dummy/app/version-checks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 3a43723

Please sign in to comment.