mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Add getEngineName and isEngine API calls
This commit is contained in:
parent
c5d18a4db9
commit
83e8f61109
@ -272,6 +272,19 @@ class Parser {
|
|||||||
return this.parseEngine();
|
return this.parseEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get engines's name
|
||||||
|
* @return {String} Engines's name or an empty string
|
||||||
|
*
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
getEngineName(toLowerCase) {
|
||||||
|
if (toLowerCase) {
|
||||||
|
return String(this.getEngine().name).toLowerCase() || '';
|
||||||
|
}
|
||||||
|
return this.getEngine().name || '';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed platform
|
* Get parsed platform
|
||||||
* @return {{}}
|
* @return {{}}
|
||||||
@ -437,6 +450,10 @@ class Parser {
|
|||||||
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
return this.getPlatformType(true) === String(platformType).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEngine(engineName) {
|
||||||
|
return this.getEngineName(true) === String(engineName).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is anything? Check if the browser is called "anything",
|
* Is anything? Check if the browser is called "anything",
|
||||||
* the OS called "anything" or the platform called "anything"
|
* the OS called "anything" or the platform called "anything"
|
||||||
|
@ -53,6 +53,21 @@ test('Parser.getOSVersion returns a correct result', (t) => {
|
|||||||
t.is(parser.getOSVersion(), '10.12.4');
|
t.is(parser.getOSVersion(), '10.12.4');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.parseEngine is being called when getEngine() called', (t) => {
|
||||||
|
const spy = sinon.spy(parser, 'parseEngine');
|
||||||
|
parser.getEngine();
|
||||||
|
t.truthy(spy.called);
|
||||||
|
parser.parseEngine.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.getEngineName gives a name of the engine', (t) => {
|
||||||
|
t.is(parser.getEngineName(), 'Blink');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parser.getEngineName gives a lower-cased name of the engine', (t) => {
|
||||||
|
t.is(parser.getEngineName(true), 'blink');
|
||||||
|
});
|
||||||
|
|
||||||
test('Skip parsing shouldn\'t parse', (t) => {
|
test('Skip parsing shouldn\'t parse', (t) => {
|
||||||
t.deepEqual((new Parser(UA, true)).getResult(), {});
|
t.deepEqual((new Parser(UA, true)).getResult(), {});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user