Skip to content

Commit 61be8fa

Browse files
hulkobaRealtin
authored andcommitted
test(utils): test getLicenseAndAuthorFromVersions
1 parent be97ff9 commit 61be8fa

File tree

1 file changed

+42
-13
lines changed

1 file changed

+42
-13
lines changed

test/utils/utils.js

+42-13
Original file line numberDiff line numberDiff line change
@@ -274,24 +274,53 @@ test('getLicenseAndAuthorFromVersions', () => {
274274
'_npmUser': {
275275
name: 'finn',
276276
email: 'finn.pauls@gmail.com'
277+
}
278+
},
279+
'2.2.2': {
280+
'repository': {
281+
'type': 'git',
282+
'url': 'git+https://github.com/best/best.git'
277283
},
278-
'2.2.2': {
279-
'repository': {
280-
'type': 'git',
281-
'url': 'git+https://github.com/best/best.git'
282-
},
283-
'license': 'MIT',
284-
'_npmUser': {
285-
name: 'finn',
286-
email: 'finn.pauls@gmail.com'
287-
}
284+
'license': 'MIT',
285+
'_npmUser': {
286+
name: 'finn',
287+
email: 'finn.pauls@gmail.com'
288288
}
289289
}
290290
}
291291
const output = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved })
292-
console.log('### output', output)
293-
// returns the last satisfying version
294-
expect(output).toEqual('9.3.1')
292+
expect(output).toMatchObject({ license: 'MIT', licenseHasChanged: false, publisher: 'finn' })
293+
})
294+
295+
test('getLicenseAndAuthorFromVersions with changed license', () => {
296+
const version = '2.2.2'
297+
const oldVersionResolved = '1.1.1'
298+
const versions = {
299+
'1.1.1': {
300+
'repository': {
301+
'type': 'git',
302+
'url': 'git+https://github.com/cat/cat.git'
303+
},
304+
'license': 'MIT',
305+
'_npmUser': {
306+
name: 'finn',
307+
email: 'finn.pauls@gmail.com'
308+
}
309+
},
310+
'2.2.2': {
311+
'repository': {
312+
'type': 'git',
313+
'url': 'git+https://github.com/best/best.git'
314+
},
315+
'license': 'kitty',
316+
'_npmUser': {
317+
name: 'finn',
318+
email: 'finn.pauls@gmail.com'
319+
}
320+
}
321+
}
322+
const output = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved })
323+
expect(output).toMatchObject({ license: 'kitty', licenseHasChanged: true, publisher: 'finn' })
295324
})
296325

297326
test('Use default env.GITHUB_URL in github compare URL', () => {

0 commit comments

Comments
 (0)