mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
51 lines
1.1 KiB
JavaScript
51 lines
1.1 KiB
JavaScript
import test from 'ava';
|
|
import sinon from 'sinon';
|
|
import Parser from '../../src/parser';
|
|
|
|
const UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1165';
|
|
const parser = new Parser(UA);
|
|
|
|
test('constructor', t => {
|
|
t.truthy(parser instanceof Parser);
|
|
});
|
|
|
|
test('getUA', t => {
|
|
t.is(parser.getUA(), UA);
|
|
});
|
|
|
|
test('test', t => {
|
|
t.truthy(parser.test(/Chrome/i));
|
|
});
|
|
|
|
test('_parseBrowser', t => {
|
|
const spy = sinon.spy(parser, '_parseBrowser');
|
|
const b = parser.getBrowser();
|
|
t.truthy(spy.called);
|
|
t.is(b.name, 'Opera');
|
|
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');
|
|
});
|
|
|
|
test('_parseOS', t => {
|
|
const spy = sinon.spy(parser, '_parseOS');
|
|
parser.getOS();
|
|
t.truthy(spy.called);
|
|
parser._parseOS.restore();
|
|
});
|
|
|
|
test('getOSName', t => {
|
|
t.is(parser.getOSName(), 'macOS');
|
|
});
|
|
|
|
test('getOSVersion', t => {
|
|
t.is(parser.getOSVersion(), '10.12.4');
|
|
});
|