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

Add Parser#getBrowserName and Parser#getBrowserVersion

This commit is contained in:
Denis Demchenko 2017-04-09 22:46:23 +03:00
parent b5aa54553f
commit c50d0449d3
2 changed files with 31 additions and 9 deletions

View File

@ -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;
} }
parseBrowserName() {}
parseBrowserVersion() {} getBrowserVersion() {
parsePlatform(){} return this.getBrowser().version;
parseOS(){} }
getPlatform(){}
getOS(){}
parseOSName(){} parseOSName(){}
parseOSVersion(){} parseOSVersion(){}
parseFullInfo(){} parseFullInfo(){}

View File

@ -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');
}); });