|
1 | | -const { exporter, sizeLabel, toMetricTimeToMerge } = require('./index'); |
| 1 | +const { exporter, toMetricTimeToMerge } = require('./index'); |
2 | 2 |
|
3 | 3 | describe('#exporter', () => { |
4 | 4 | const composeDatabaseMock = payload => { |
@@ -41,108 +41,3 @@ describe('#exporter', () => { |
41 | 41 | expect(process.stdout.write).toHaveBeenCalledTimes(0); |
42 | 42 | }); |
43 | 43 | }); |
44 | | - |
45 | | -describe('#sizeLabel', () => { |
46 | | - test('returns the correct size label per line count', () => { |
47 | | - const useCases = [ |
48 | | - { |
49 | | - lineCount: NaN, |
50 | | - expectedLabel: undefined, |
51 | | - }, |
52 | | - { |
53 | | - lineCount: -1, |
54 | | - expectedLabel: undefined, |
55 | | - }, |
56 | | - { |
57 | | - lineCount: 0, |
58 | | - expectedLabel: 'size_xs', |
59 | | - }, |
60 | | - { |
61 | | - lineCount: 9, |
62 | | - expectedLabel: 'size_xs', |
63 | | - }, |
64 | | - { |
65 | | - lineCount: 10, |
66 | | - expectedLabel: 'size_s', |
67 | | - }, |
68 | | - { |
69 | | - lineCount: 29, |
70 | | - expectedLabel: 'size_s', |
71 | | - }, |
72 | | - { |
73 | | - lineCount: 30, |
74 | | - expectedLabel: 'size_m', |
75 | | - }, |
76 | | - { |
77 | | - lineCount: 99, |
78 | | - expectedLabel: 'size_m', |
79 | | - }, |
80 | | - { |
81 | | - lineCount: 100, |
82 | | - expectedLabel: 'size_l', |
83 | | - }, |
84 | | - { |
85 | | - lineCount: 499, |
86 | | - expectedLabel: 'size_l', |
87 | | - }, |
88 | | - { |
89 | | - lineCount: 500, |
90 | | - expectedLabel: 'size_xl', |
91 | | - }, |
92 | | - { |
93 | | - lineCount: 999, |
94 | | - expectedLabel: 'size_xl', |
95 | | - }, |
96 | | - { |
97 | | - lineCount: 1000, |
98 | | - expectedLabel: 'size_xxl', |
99 | | - }, |
100 | | - ]; |
101 | | - |
102 | | - useCases.forEach(useCase => { |
103 | | - expect(sizeLabel(useCase.lineCount)).toEqual(useCase.expectedLabel); |
104 | | - }); |
105 | | - }); |
106 | | -}); |
107 | | - |
108 | | -describe('#toMetricTimeToMerge', () => { |
109 | | - test('calculates the elapsed time between the creation of a pull request and the merging of the pull request', () => { |
110 | | - const useCases = [ |
111 | | - { |
112 | | - data: { |
113 | | - createdAt: '2019-05-02T10:00:00Z', |
114 | | - mergedAt: '2019-05-02T11:00:00Z', |
115 | | - }, |
116 | | - differenceSeconds: 60 * 60, // one hour |
117 | | - }, |
118 | | - { |
119 | | - data: { |
120 | | - createdAt: '2019-05-02T10:00:00Z', |
121 | | - mergedAt: '2019-05-03T10:00:00Z', |
122 | | - }, |
123 | | - differenceSeconds: 60 * 60 * 24, // one day |
124 | | - }, |
125 | | - { |
126 | | - data: { |
127 | | - createdAt: '2019-05-02T10:00:00Z', |
128 | | - mergedAt: '2019-05-09T10:00:00Z', |
129 | | - }, |
130 | | - differenceSeconds: 60 * 60 * 24 * 7, // one week |
131 | | - }, |
132 | | - { |
133 | | - data: { |
134 | | - createdAt: '2019-05-02T10:00:00Z', |
135 | | - mergedAt: '2019-06-02T10:00:00Z', |
136 | | - }, |
137 | | - differenceSeconds: 60 * 60 * 24 * 31, // a month of 31 days |
138 | | - }, |
139 | | - ]; |
140 | | - |
141 | | - useCases.forEach(useCase => { |
142 | | - const result = toMetricTimeToMerge(useCase.data, 'path.to.metric'); |
143 | | - expect(result).toEqual( |
144 | | - `path.to.metric ${useCase.differenceSeconds} 1556791200` |
145 | | - ); |
146 | | - }); |
147 | | - }); |
148 | | -}); |
0 commit comments