-
Notifications
You must be signed in to change notification settings - Fork 83
/
log_test.js
89 lines (87 loc) · 3.43 KB
/
log_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';
var command = require('../lib/commands').log;
var Test = require('./_common');
describe('log', function () {
it('should log with default pretty format', function (done) {
var options = {
noMerges: false
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format], [null, { stdout: '' }])
.run(done);
});
it('should log with specified pretty format', function (done) {
var customFormat = 'format:some custom format';
var options = {
pretty: customFormat
};
new Test(command, options)
.expect(['log', '--pretty=' + customFormat, '--no-merges'], [null, { stdout: '' }])
.run(done);
});
it('should log the specified number of logs', function (done) {
var options = {
noMerges: false,
number: 10
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '-n', 10], [null, { stdout: '' }])
.run(done);
});
it('should not log merges if noMerges is true', function (done) {
var options = {
noMerges: true
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges'], [null, { stdout: '' }])
.run(done);
});
it('should log merges if noMerges is not defined', function (done) {
var options = {
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges'], [null, { stdout: '' }])
.run(done);
});
it('should order by date is dateOrder is defined', function (done) {
var options = {
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges'], [null, { stdout: '' }])
.run(done);
});
it('should order by date if --before or --after is used', function (done) {
var options = {
noMerges: false,
dateOrder: true
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--date-order'], [null, { stdout: '' }])
.run(done);
});
it('should log from a specified branch to HEAD if from is used', function (done) {
var options = {
from: '1234'
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges', '1234..HEAD'], [null, { stdout: '' }])
.run(done);
});
it('should log from a specified branch to a specfied branch if from and to are used', function (done) {
var options = {
from: '1234',
to: '6789'
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges', '1234..6789'], [null, { stdout: '' }])
.run(done);
});
it('should parse logs correctly when newlines exist in log body', function (done) {
var logs = '{ "hash": "hash", "author": { "name": "blah", "email": "blah@example.com" }, "date": "somedate", "subject": "thing", "body": "this\nhas\nnewlines\n:(" }--grunt-gitlog-separator--';
var options = {
};
new Test(command, options)
.expect(['log', '--pretty=format:' + command.format, '--no-merges'], [null, { stdout: logs }])
.run(done);
});
});