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 919d1b2
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/dummy/app/version-checks.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import Ember from 'ember';

const { VERSION } = Ember;
export const hasPositionalParams = hasEmberVersion(1, 13);
export const hasReliablePositionalParams = hasEmberVersion(2, 3);

const EMBERS_WITHOUT_POSITIONAL_PARAMS = [
'1.12',
'1.11',
];

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) {
var numbers = Ember.VERSION.split('-')[0].split('.');
var actualMajor = parseInt(numbers[0], 10);
var actualMinor = parseInt(numbers[1], 10);
return actualMajor > major || (actualMajor === major && actualMinor >= minor);
}

0 comments on commit 919d1b2

Please sign in to comment.