1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Get rid of semver and use old comparison which is more applicable

This commit is contained in:
Denis Demchenko
2018-07-02 23:30:48 +03:00
parent 6030eb9e5d
commit 4ab0d9dfd3
4 changed files with 137 additions and 11 deletions

View File

@@ -58,13 +58,17 @@ test('Skip parsing shouldn\'t parse', (t) => {
});
test('Parser.check should make simple check', (t) => {
t.is(parser.semverCheck({ opera: '>42' }), true);
t.is(parser.check({ opera: '>42' }), true);
});
test('Parser.check should make simple check', (t) => {
t.is(parser.semverCheck({
t.is(parser.check({
macos: {
opera: '>42',
safari: '>11',
},
ios: {
safari: '>10',
},
opera: '>42',
}), true);
});

View File

@@ -2,6 +2,7 @@ import test from 'ava';
import {
getFirstMatch,
getWindowsVersionName,
compareVersions,
} from '../../src/utils';
test('getFirstMatch', (t) => {
@@ -13,3 +14,35 @@ test('getWindowsVersionName', (t) => {
t.is(getWindowsVersionName('NT 5.0'), '2000');
t.is(getWindowsVersionName('XXX'), void 0);
});
test('compareVersions', (t) => {
const comparisionsTasks = [
['9.0', '10', -1],
['11', '10', 1],
['1.10.2.1', '1.8.2.1.90', 1],
['1.010.2.1', '1.08.2.1.90', 1],
['1.10.2.1', '1.10.2.1', 0],
['1.10.2.1', '1.0800.2', -1],
['1.0.0-alpha', '1.0.0-alpha.1', -1],
['1.0.0-alpha.1', '1.0.0-alpha.beta', -1],
['1.0.0-alpha.beta', '1.0.0-beta', -1],
['1.0.0-beta', '1.0.0-beta.2', -1],
['1.0.0-beta.11', '1.0.0-rc.1', -1],
['1.0.0-rc.1', '1.0.0', -1],
];
comparisionsTasks.forEach((testingParams) => {
const versionA = testingParams[0];
const versionB = testingParams[1];
const result = testingParams[2];
let matching = ' == ';
if (result > 0) {
matching = ' > ';
} else if (result < 0) {
matching = ' < ';
}
t.is(compareVersions(versionA, versionB), result, `version ${versionA} should be ${matching} version ${versionB}`);
});
});