-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtest.js
89 lines (76 loc) · 3.73 KB
/
test.js
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
require('mocha');
var assert = require('assert');
var authors = require('./');
describe('authors:', function() {
it('should return empty fields when info is missing.', function() {
assert.deepEqual(authors(''), [{name: '', email: '', url: ''}]);
});
it('should parse an array of author strings', function() {
assert.deepEqual(authors(['Jon Schlinkert <jon@foo.email> (https://github.com/jonschlinkert)']), [
{name: 'Jon Schlinkert', email: 'jon@foo.email', url: 'https://github.com/jonschlinkert'}
]);
});
it('should return a parsed author object.', function() {
assert.deepEqual(authors('Jon Schlinkert <jon@foo.email> (https://github.com/jonschlinkert)'), [
{name: 'Jon Schlinkert', email: 'jon@foo.email', url: 'https://github.com/jonschlinkert'}
]);
});
it('should return an array of author objects.', function() {
var fixture = 'Jon Schlinkert <jon@foo.email> (https://github.com/jonschlinkert)\nBrian Woodward <brian@bar.email> (https://github.com/doowb)';
assert.deepEqual(authors(fixture), [
{name: 'Jon Schlinkert', email: 'jon@foo.email', url: 'https://github.com/jonschlinkert'},
{name: 'Brian Woodward', email: 'brian@bar.email', url: 'https://github.com/doowb'}
]);
});
it('should ignore empty lines', function() {
var fixture = '\nJon Schlinkert <jon@foo.email> (https://github.com/jonschlinkert)\n\nBrian Woodward <brian@bar.email> (https://github.com/doowb)\n\n';
assert.deepEqual(authors(fixture), [
{name: 'Jon Schlinkert', email: 'jon@foo.email', url: 'https://github.com/jonschlinkert'},
{name: 'Brian Woodward', email: 'brian@bar.email', url: 'https://github.com/doowb'}
]);
});
it('should return name and email only .', function() {
var fixture = 'Jon Schlinkert (https://github.com/jonschlinkert)\nBrian Woodward (https://github.com/doowb)';
assert.deepEqual(authors(fixture), [
{name: 'Jon Schlinkert', email: '', url: 'https://github.com/jonschlinkert'},
{name: 'Brian Woodward', email: '', url: 'https://github.com/doowb'}
]);
});
it('should return mixed properties.', function() {
assert.deepEqual(authors('Jon Schlinkert \nBrian Woodward <brian@bar.email> (https://github.com/doowb)'), [
{name: 'Jon Schlinkert', email: '', url: ''},
{name: 'Brian Woodward', email: 'brian@bar.email', url: 'https://github.com/doowb'}
]);
});
it('should return mixed properties.', function() {
assert.deepEqual(authors('<jon@foo.email> (https://github.com/jonschlinkert)\nBrian Woodward <brian@bar.email> '), [
{name: '', email: 'jon@foo.email', url: 'https://github.com/jonschlinkert'},
{name: 'Brian Woodward', email: 'brian@bar.email', url: ''}
]);
});
it('should return mixed properties.', function() {
assert.deepEqual(authors('<jon@foo.email> \n<brian@bar.email> (https://github.com/doowb)'), [
{name: '', email: 'jon@foo.email', url: ''},
{name: '', email: 'brian@bar.email', url: 'https://github.com/doowb'}
]);
});
it('should return name only.', function() {
assert.deepEqual(authors('Jon Schlinkert\nBrian Woodward'), [
{name: 'Jon Schlinkert', email: '', url: ''},
{name: 'Brian Woodward', email: '', url: ''}
])
});
it('should return email only.', function() {
assert.deepEqual(authors('<jon@foo.email>\n<brian@bar.email>'), [
{name: '', email: 'jon@foo.email', url: ''},
{name: '', email: 'brian@bar.email', url: ''}
]);
});
it('should return url only.', function() {
assert.deepEqual(authors('(https://github.com/jonschlinkert)\n(https://github.com/doowb)'), [
{name: '', email: '', url: 'https://github.com/jonschlinkert'},
{name: '', email: '', url: 'https://github.com/doowb'}
]);
});
});