forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.spec.js
More file actions
75 lines (67 loc) · 2.46 KB
/
table.spec.js
File metadata and controls
75 lines (67 loc) · 2.46 KB
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
const moment = require('moment');
const config = require('../../src/include/config');
const Report = require('../../src/models/report');
const table = require('../../src/output/table');
const Sinon = require('sinon');
describe('Table output', () => {
it('Renders projects if more than one', () => {
const issues = [
{
times: [
{
user: "user1",
project_namespace: "project1",
seconds: 360,
date: moment('2024-06-06 00:00:00')
},
{
user: "user2",
project_namespace: "project2",
seconds: 720,
date: moment('2024-06-06 00:00:00')
}
],
stats: {time_estimate: 0, total_time_spent: 0}
}
];
const projectsMatcher = Sinon.match('project1').and(Sinon.match('project2'))
let reportConfig = new config();
reportConfig.set('report', ['stats'])
let report = new Report(reportConfig);
report.issues = issues;
report.mergeRequests = [];
let out = new table(reportConfig, report);
let mdMock = Sinon.mock(out);
mdMock.expects('headline').once();
mdMock.expects('write').once().withArgs(projectsMatcher);
out.make();
});
it('Does not render single project', () => {
const issues = [
{
times: [
{
user: "user2",
project_namespace: "project2",
seconds: 720,
date: moment('2024-06-06 00:00:00')
}
],
stats: {time_estimate: 0, total_time_spent: 0}
}
];
const projectsMatcher = Sinon.match(function(value) {
return ((typeof(value) === 'string') && (/project2/.test(value) === false));
})
let reportConfig = new config();
reportConfig.set('report', ['stats'])
let report = new Report(reportConfig);
report.issues = issues;
report.mergeRequests = [];
let out = new table(reportConfig, report);
let mdMock = Sinon.mock(out);
mdMock.expects('headline').once();
mdMock.expects('write').once().withArgs(projectsMatcher);
out.make();
});
});