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'; import {
getFirstMatch,
function getWindowsVersionName(version) { getWindowsVersionName,
switch (version) { } from './utils';
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;
}
}
export default [ export default [
/* Windows Phone */ /* Windows Phone */

View File

@ -34,6 +34,22 @@ class Utils {
} }
return void (0); 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; module.exports = Utils;

View File

@ -1,7 +1,15 @@
import test from 'ava'; import test from 'ava';
import { getFirstMatch } from '../../src/utils'; import {
getFirstMatch,
getWindowsVersionName,
} from '../../src/utils';
test('getFirstMatch', (t) => { test('getFirstMatch', (t) => {
const matchedVersion = getFirstMatch(/version\/(\S+)/i, 'Chrome Version/11.11.11'); const matchedVersion = getFirstMatch(/version\/(\S+)/i, 'Chrome Version/11.11.11');
t.is(matchedVersion, '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);
});