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

19 lines
625 B
JavaScript
Raw Permalink Normal View History

2018-06-30 14:25:47 +00:00
import test from 'ava';
import Bowser from '../../src/bowser';
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';
2018-07-05 19:58:14 +00:00
const browser = Bowser.getParser(UA);
2018-06-30 14:25:47 +00:00
test('Bowser`s constructor returns a Parser instance', (t) => {
t.truthy(browser instanceof Parser);
});
test('Bowser`s constructor fails if UA is empty', (t) => {
2018-07-05 19:58:14 +00:00
t.throws(() => (Bowser.getParser()));
2018-06-30 14:25:47 +00:00
});
test('Bowser.parse parses UA and returns result', (t) => {
t.deepEqual(Bowser.parse(UA), browser.getResult());
});