mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Fix getPlatformType, write tests
This commit is contained in:
parent
48638e7363
commit
e759592884
@ -198,14 +198,14 @@ class Parser {
|
|||||||
* @param {Boolean} toLowerCase
|
* @param {Boolean} toLowerCase
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
getPlatformName(toLowerCase) {
|
getPlatformType(toLowerCase) {
|
||||||
const { name } = this.getPlatform();
|
const { type } = this.getPlatform();
|
||||||
|
|
||||||
if (toLowerCase) {
|
if (toLowerCase) {
|
||||||
return String(name).toLowerCase() || '';
|
return String(type).toLowerCase() || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return name || '';
|
return type || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -342,8 +342,18 @@ class Parser {
|
|||||||
return this.getOSName(true) === String(osName).toLowerCase();
|
return this.getOSName(true) === String(osName).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
isPlatform(platformName) {
|
isPlatform(platformType) {
|
||||||
return this.getPlatformName(true) === String(platformName).toLowerCase();
|
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is anything? Check if the browser is called "anything",
|
||||||
|
* the OS called "anything" or the platform called "anything"
|
||||||
|
* @param {String} anything
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
is(anything) {
|
||||||
|
return this.isBrowser(anything) || this.isOs(anything) || this.isPlatform(anything);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,3 +72,9 @@ test('Parser.check should make complex comparison', (t) => {
|
|||||||
opera: '>42',
|
opera: '>42',
|
||||||
}), true);
|
}), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.is should pass', (t) => {
|
||||||
|
t.is(parser.is('opera'), true);
|
||||||
|
t.is(parser.is('desktop'), true);
|
||||||
|
t.is(parser.is('macos'), true);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user