summaryrefslogtreecommitdiff
path: root/node_modules/ua-parser/js/test/old-api.js
blob: 7b9b6e250c5416f3b8cf0c12159efca3513fd515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Documenting current behaviour for backwards compat reqs.

var assert = require('assert'),
    parse = require('../index').parse;

var USER_AGENT_STRING = 'Mozilla/5.0 (Windows NT 6.1; rv:2.0b6pre) Gecko/20100903 Firefox/4.0b6pre Firefox/4.0b6pre';

suite('parse function', function() {
  test('output with valid UA string', function() {
    var output = parse(USER_AGENT_STRING);
    assert.strictEqual(output.family, 'Firefox Beta');
    assert.strictEqual(output.major, 4);
    assert.strictEqual(output.minor, 0);
    assert.ok(isNaN(output.patch));
  });

  test('output with invalid UA string', function() {
    var output = parse('');
    assert.strictEqual(output.family, 'Other');
    assert.strictEqual(output.major, undefined);
    assert.strictEqual(output.minor, undefined);
    assert.strictEqual(output.patch, undefined);
  });
});