-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
106 lines (97 loc) · 3.09 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*!
* parse-copyright <https://github.com/jonschlinkert/parse-copyright>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var assert = require('assert');
var parse = require('./');
it.only('should parse a copyright statement:', function () {
var parsed = parse('abc\nCopyright (c) 2015, Jon Schlinkert.\nxyz');
assert.deepEqual(parsed, [{
statement: 'Copyright (c) 2015, Jon Schlinkert',
prefix: 'Copyright',
symbol: '(c)',
dateRange: '2015',
first: '2015',
latest: '2015',
author: 'Jon Schlinkert'
}]);
});
it('should parse multiple copyright statements:', function () {
var parsed = parse('abc\nCopyright (c) 2013, Jon Schlinkert.\nxyz\nabc\nCopyright (c) 2015, Jon Schlinkert.\nxyz');
assert.deepEqual(parsed, [{
statement: 'Copyright (c) 2013, Jon Schlinkert',
prefix: 'Copyright',
symbol: '(c)',
dateRange: '2013',
first: '2013',
latest: '2013',
author: 'Jon Schlinkert'
}, {
statement: 'Copyright (c) 2015, Jon Schlinkert',
prefix: 'Copyright',
symbol: '(c)',
dateRange: '2015',
first: '2015',
latest: '2015',
author: 'Jon Schlinkert'
}]);
});
it('should parse a range of years:', function () {
assert.deepEqual(parse('abc\nCopyright (c) 2013-2015, Jon Schlinkert.\nxyz'), [{
statement: 'Copyright (c) 2013-2015, Jon Schlinkert',
prefix: 'Copyright',
symbol: '(c)',
dateRange: '2013-2015',
first: '2013',
latest: '2015',
author: 'Jon Schlinkert'
}]);
assert.deepEqual(parse('# Copyright (C) 1986-1993, 1998, 2004, 2007-2010 Some Guy'), [{
statement: 'Copyright (C) 1986-1993, 1998, 2004, 2007-2010 Some Guy',
prefix: 'Copyright',
symbol: '(C)',
dateRange: '1986-1993, 1998, 2004, 2007-2010',
first: '1986',
latest: '2010',
author: 'Some Guy'
}]);
});
it('should parse a statement without an author:', function () {
assert.deepEqual(parse('# Copyright (C) 1986-1993, 1998, 2004, 2007-2010'), [{
statement: 'Copyright (C) 1986-1993, 1998, 2004, 2007-2010',
prefix: 'Copyright',
symbol: '(C)',
dateRange: '1986-1993, 1998, 2004, 2007-2010',
first: '1986',
latest: '2010'
}]);
});
it('should remove non-copyright material:', function () {
assert.deepEqual(parse('." Copyright (c) 2011, Joyent, Inc. All Rights Reserved.'), [{
statement: 'Copyright (c) 2011, Joyent, Inc',
prefix: 'Copyright',
symbol: '(c)',
dateRange: '2011',
first: '2011',
latest: '2011',
author: 'Joyent, Inc'
}]);
});
it('should parse complex statements:', function () {
assert.deepEqual(parse('/* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>'), [{
statement: 'Copyright (C) 1999 Masanao Izumo ',
prefix: 'Copyright',
symbol: '(C)',
dateRange: '1999',
first: '1999',
latest: '1999',
author: 'Masanao Izumo'
}]);
});
it('should return an empty array when no valid copyright statement is found:', function () {
assert.deepEqual(parse('// assert.equal(match("Copyright (c) 2013, Jon Schlinkert.")[0], "2013-2015");'), []);
assert.deepEqual(parse('foo'), []);
});