Add Parser#getBrowserName and Parser#getBrowserVersion

pull/227/head
Denis Demchenko 7 years ago
parent b5aa54553f
commit c50d0449d3

@ -26,6 +26,15 @@ class Parser {
return this._ua; return this._ua;
} }
/**
* Test a UA string for a regexp
* @param {RegExp} regex
* @return {Boolean}
*/
test(regex) {
return regex.test(this._ua);
}
/** /**
* Get parsed browser object * Get parsed browser object
* @return {Object} * @return {Object}
@ -71,18 +80,22 @@ class Parser {
} }
/** /**
* Test a UA string for a regexp * Get browser's name
* @param {RegExp} regex * @return {String} Browser's name
* @return {Boolean} *
* @public
*/ */
test(regex) { getBrowserName() {
return regex.test(this._ua); return this.getBrowser().name;
}
getBrowserVersion() {
return this.getBrowser().version;
} }
parseBrowserName() {} getPlatform(){}
parseBrowserVersion() {} getOS(){}
parsePlatform(){}
parseOS(){}
parseOSName(){} parseOSName(){}
parseOSVersion(){} parseOSVersion(){}
parseFullInfo(){} parseFullInfo(){}

@ -23,4 +23,13 @@ test('_parseBrowser', t => {
t.truthy(spy.called); t.truthy(spy.called);
t.is(b.name, 'Opera'); t.is(b.name, 'Opera');
t.is(b.version, '43.0.2442.1165'); t.is(b.version, '43.0.2442.1165');
parser._parseBrowser.restore();
});
test('getBrowserName', t => {
t.is(parser.getBrowserName(), 'Opera');
});
test('getBrowserVersion', t => {
t.is(parser.getBrowserVersion(), '43.0.2442.1165');
}); });

Loading…
Cancel
Save