1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Continue writing

This commit is contained in:
Denis Demchenko
2017-04-09 17:13:00 +03:00
parent 575ba8076e
commit 3bb6654320
8 changed files with 164 additions and 25 deletions

17
test/unit/parser.js Normal file
View File

@@ -0,0 +1,17 @@
import test from 'ava';
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));
});

7
test/unit/utils.js Normal file
View File

@@ -0,0 +1,7 @@
import test from 'ava';
import { getFirstMatch } from '../../src/utils';
test('getFirstMatch', t => {
const matchedVersion = getFirstMatch(/version\/(\S+)/i, 'Chrome Version/11.11.11');
t.is(matchedVersion, '11.11.11');
});