1
0
mirror of https://github.com/lancedikson/bowser synced 2024-10-27 20:34:22 +00:00

Move getWindowsVersionName to utils

This commit is contained in:
Denis Demchenko 2018-06-30 19:40:10 +03:00
parent 3530ca1c70
commit 9cb04fcbae
3 changed files with 29 additions and 18 deletions

View File

@ -1,20 +1,7 @@
import { getFirstMatch } from './utils';
function getWindowsVersionName(version) {
switch (version) {
case 'NT': return 'NT';
case 'XP': return 'XP';
case 'NT 5.0': return '2000';
case 'NT 5.1': return 'XP';
case 'NT 5.2': return '2003';
case 'NT 6.0': return 'Vista';
case 'NT 6.1': return '7';
case 'NT 6.2': return '8';
case 'NT 6.3': return '8.1';
case 'NT 10.0': return '10';
default: return undefined;
}
}
import {
getFirstMatch,
getWindowsVersionName,
} from './utils';
export default [
/* Windows Phone */

View File

@ -34,6 +34,22 @@ class Utils {
}
return void (0);
}
static getWindowsVersionName(version) {
switch (version) {
case 'NT': return 'NT';
case 'XP': return 'XP';
case 'NT 5.0': return '2000';
case 'NT 5.1': return 'XP';
case 'NT 5.2': return '2003';
case 'NT 6.0': return 'Vista';
case 'NT 6.1': return '7';
case 'NT 6.2': return '8';
case 'NT 6.3': return '8.1';
case 'NT 10.0': return '10';
default: return undefined;
}
}
}
module.exports = Utils;

View File

@ -1,7 +1,15 @@
import test from 'ava';
import { getFirstMatch } from '../../src/utils';
import {
getFirstMatch,
getWindowsVersionName,
} from '../../src/utils';
test('getFirstMatch', (t) => {
const matchedVersion = getFirstMatch(/version\/(\S+)/i, 'Chrome Version/11.11.11');
t.is(matchedVersion, '11.11.11');
});
test('getWindowsVersionName', (t) => {
t.is(getWindowsVersionName('NT 5.0'), '2000');
t.is(getWindowsVersionName('XXX'), void 0);
});