From 61be8fa0b498b2a587537e9304448b55f0735cb4 Mon Sep 17 00:00:00 2001 From: hulkoba Date: Thu, 27 Jun 2019 11:49:01 +0200 Subject: [PATCH] test(utils): test getLicenseAndAuthorFromVersions --- test/utils/utils.js | 55 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/test/utils/utils.js b/test/utils/utils.js index c265a7e9..4504cd75 100644 --- a/test/utils/utils.js +++ b/test/utils/utils.js @@ -274,24 +274,53 @@ test('getLicenseAndAuthorFromVersions', () => { '_npmUser': { name: 'finn', email: 'finn.pauls@gmail.com' + } + }, + '2.2.2': { + 'repository': { + 'type': 'git', + 'url': 'git+https://github.com/best/best.git' }, - '2.2.2': { - 'repository': { - 'type': 'git', - 'url': 'git+https://github.com/best/best.git' - }, - 'license': 'MIT', - '_npmUser': { - name: 'finn', - email: 'finn.pauls@gmail.com' - } + 'license': 'MIT', + '_npmUser': { + name: 'finn', + email: 'finn.pauls@gmail.com' } } } const output = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved }) - console.log('### output', output) - // returns the last satisfying version - expect(output).toEqual('9.3.1') + expect(output).toMatchObject({ license: 'MIT', licenseHasChanged: false, publisher: 'finn' }) +}) + +test('getLicenseAndAuthorFromVersions with changed license', () => { + const version = '2.2.2' + const oldVersionResolved = '1.1.1' + const versions = { + '1.1.1': { + 'repository': { + 'type': 'git', + 'url': 'git+https://github.com/cat/cat.git' + }, + 'license': 'MIT', + '_npmUser': { + name: 'finn', + email: 'finn.pauls@gmail.com' + } + }, + '2.2.2': { + 'repository': { + 'type': 'git', + 'url': 'git+https://github.com/best/best.git' + }, + 'license': 'kitty', + '_npmUser': { + name: 'finn', + email: 'finn.pauls@gmail.com' + } + } + } + const output = getLicenseAndAuthorFromVersions({ versions, version, oldVersionResolved }) + expect(output).toMatchObject({ license: 'kitty', licenseHasChanged: true, publisher: 'finn' }) }) test('Use default env.GITHUB_URL in github compare URL', () => {