@@ -112,6 +112,195 @@ const comparisonFixture = {
112
112
}
113
113
} ;
114
114
115
+ const associatedPullRequestsMajor = {
116
+ "repository" : {
117
+ "name" : "adyen-node-api-library" ,
118
+ "ref" : {
119
+ "compare" : {
120
+ "aheadBy" : 8 ,
121
+ "commits" : {
122
+ "edges" : [
123
+ {
124
+ "node" : {
125
+ "message" : "Another commit in the same PR non squashed" ,
126
+ "associatedPullRequests" : {
127
+ "edges" : [
128
+ {
129
+ "node" : {
130
+ "number" : 20 ,
131
+ "labels" : {
132
+ "nodes" : [
133
+ {
134
+ "name" : "Breaking change"
135
+ }
136
+ ]
137
+ }
138
+ }
139
+ }
140
+ ]
141
+ }
142
+ }
143
+ } ,
144
+ {
145
+ "node" : {
146
+ "message" : "Fixing the constructor" ,
147
+ "associatedPullRequests" : {
148
+ "edges" : [
149
+ {
150
+ "node" : {
151
+ "number" : 10 ,
152
+ "labels" : {
153
+ "nodes" : [
154
+ {
155
+ "name" : "Fix"
156
+ }
157
+ ]
158
+ }
159
+ }
160
+ }
161
+ ]
162
+ }
163
+ }
164
+ } ,
165
+ {
166
+ "node" : {
167
+ "message" : "Upgrade some service" ,
168
+ "associatedPullRequests" : {
169
+ "edges" : [
170
+ {
171
+ "node" : {
172
+ "number" : 20 ,
173
+ "labels" : {
174
+ "nodes" : [
175
+ {
176
+ "name" : "Feature"
177
+ }
178
+ ]
179
+ }
180
+ }
181
+ }
182
+ ]
183
+ }
184
+ }
185
+ } ,
186
+ {
187
+ "node" : {
188
+ "message" : "Update CODEOWNERS (#965)" ,
189
+ "associatedPullRequests" : {
190
+ "edges" : [
191
+ {
192
+ "node" : {
193
+ "number" : 30 ,
194
+ "labels" : {
195
+ "nodes" : [ ]
196
+ }
197
+ }
198
+ }
199
+ ]
200
+ }
201
+ }
202
+ }
203
+ ]
204
+ }
205
+ }
206
+ }
207
+ }
208
+ } ;
209
+
210
+ const associatedPullRequestsMinor = {
211
+ "repository" : {
212
+ "name" : "adyen-node-api-library" ,
213
+ "ref" : {
214
+ "compare" : {
215
+ "aheadBy" : 8 ,
216
+ "commits" : {
217
+ "edges" : [
218
+ {
219
+ "node" : {
220
+ "message" : "Another commit in the same PR non squashed" ,
221
+ "associatedPullRequests" : {
222
+ "edges" : [
223
+ {
224
+ "node" : {
225
+ "number" : 20 ,
226
+ "labels" : {
227
+ "nodes" : [
228
+ {
229
+ "name" : ""
230
+ }
231
+ ]
232
+ }
233
+ }
234
+ }
235
+ ]
236
+ }
237
+ }
238
+ } ,
239
+ {
240
+ "node" : {
241
+ "message" : "Fixing the constructor" ,
242
+ "associatedPullRequests" : {
243
+ "edges" : [
244
+ {
245
+ "node" : {
246
+ "number" : 10 ,
247
+ "labels" : {
248
+ "nodes" : [
249
+ {
250
+ "name" : "Feature"
251
+ }
252
+ ]
253
+ }
254
+ }
255
+ }
256
+ ]
257
+ }
258
+ }
259
+ } ,
260
+ {
261
+ "node" : {
262
+ "message" : "Upgrade some service" ,
263
+ "associatedPullRequests" : {
264
+ "edges" : [
265
+ {
266
+ "node" : {
267
+ "number" : 20 ,
268
+ "labels" : {
269
+ "nodes" : [
270
+ {
271
+ "name" : "Fix"
272
+ }
273
+ ]
274
+ }
275
+ }
276
+ }
277
+ ]
278
+ }
279
+ }
280
+ } ,
281
+ {
282
+ "node" : {
283
+ "message" : "Update CODEOWNERS (#965)" ,
284
+ "associatedPullRequests" : {
285
+ "edges" : [
286
+ {
287
+ "node" : {
288
+ "number" : 30 ,
289
+ "labels" : {
290
+ "nodes" : [ ]
291
+ }
292
+ }
293
+ }
294
+ ]
295
+ }
296
+ }
297
+ }
298
+ ]
299
+ }
300
+ }
301
+ }
302
+ }
303
+ } ;
115
304
beforeEach ( ( ) => {
116
305
// Reset env variables
117
306
delete process . env . CURRENT_VERSION ;
@@ -134,7 +323,7 @@ test('Detect changes', async t => {
134
323
135
324
assert . strictEqual ( ver , 'major' ) ;
136
325
} ) ;
137
-
326
+
138
327
await t . test ( 'Zero changes' , t => {
139
328
let sync = structuredClone ( comparisonFixture ) ;
140
329
sync . repository . ref . compare . aheadBy = 0 ;
@@ -158,6 +347,7 @@ test('Detect changes', async t => {
158
347
} ) ;
159
348
} ) ;
160
349
350
+
161
351
test ( 'Get next version' , async t => {
162
352
await t . test ( 'Major' , async t => {
163
353
const ver = release . nextVersion ( '13.1.2' , 'major' ) ;
@@ -229,4 +419,21 @@ test('Bump', async t => {
229
419
await release . bump ( options ) ;
230
420
231
421
assert . strictEqual ( core . setOutput . mock . calls . length , 3 ) ;
232
- } ) ;
422
+ } ) ;
423
+
424
+
425
+ test ( 'Calculate version major' , async t => {
426
+ await t . test ( 'Major' , t => {
427
+ const ver = release . detectChanges ( associatedPullRequestsMajor ) ;
428
+
429
+ assert . strictEqual ( ver , 'major' ) ;
430
+ } )
431
+ } ) ;
432
+
433
+ test ( 'Calculate version minor' , async t => {
434
+ await t . test ( 'Minor' , t => {
435
+ const ver = release . detectChanges ( associatedPullRequestsMinor ) ;
436
+
437
+ assert . strictEqual ( ver , 'minor' ) ;
438
+ } ) ;
439
+ } ) ;
0 commit comments