diff --git a/lib/workers/repository/process/lookup/index.js b/lib/workers/repository/process/lookup/index.js index e6d257c6c8977cc3b271b7c40fded4316bb41356..4137a3dcacb36cafc3078cc9d7d0bc6daf8550e9 100644 --- a/lib/workers/repository/process/lookup/index.js +++ b/lib/workers/repository/process/lookup/index.js @@ -21,6 +21,7 @@ async function lookupUpdates(config) { matches, getNewValue, } = versioning(config.versionScheme); + const updates = []; const dependency = await getDependency(config.purl, config); if (!dependency) { // If dependency lookup fails then warn and return @@ -32,8 +33,9 @@ async function lookupUpdates(config) { { dependency: depName, packageFile: config.packageFile }, result.message ); - // TODO: return an object - return [result]; + // TODO: return warnings in own field + updates.push(result); + return { updates }; } const { releases } = dependency; // Filter out any results from datasource that don't comply with our versioning scheme @@ -45,28 +47,29 @@ async function lookupUpdates(config) { const message = `No versions returned from registry for this package`; logger.warn({ dependency }, message); // TODO: return an object - return [ + updates.push([ { type: 'warning', message, }, - ]; + ]); + return { updates }; } // Check that existing constraint can be satisfied const allSatisfyingVersions = allVersions.filter(version => matches(version, currentValue) ); - const updates = []; if (!allSatisfyingVersions.length) { const rollback = getRollbackUpdate(config, allVersions); // istanbul ignore if if (!rollback) { - return [ + updates.push([ { type: 'warning', message: `Can't find version matching ${currentValue} for ${depName}`, }, - ]; + ]); + return { updates }; } updates.push(rollback); } @@ -93,7 +96,7 @@ async function lookupUpdates(config) { allVersions ); if (!filteredVersions.length) { - return updates; + return { updates }; } const buckets = {}; for (const toVersion of filteredVersions) { @@ -132,9 +135,11 @@ async function lookupUpdates(config) { if (!(repositoryUrl && repositoryUrl.length)) { repositoryUrl = null; } - return updates - .concat(Object.values(buckets)) - .map(update => ({ ...update, repositoryUrl })); + return { + updates: updates + .concat(Object.values(buckets)) + .map(update => ({ ...update, repositoryUrl })), + }; } function getType(config, fromVersion, toVersion) { diff --git a/test/workers/repository/process/lookup/index.spec.js b/test/workers/repository/process/lookup/index.spec.js index 96a8c4b131af49d74125a5db61c9d46ad3d097b4..c3c0c300dcd8dd0b40dc3e08f2b81067c98ef1a1 100644 --- a/test/workers/repository/process/lookup/index.spec.js +++ b/test/workers/repository/process/lookup/index.spec.js @@ -28,7 +28,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns rollback for ranged version', async () => { config.currentValue = '^0.9.99'; @@ -37,7 +37,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports minor and major upgrades for tilde ranges', async () => { config.currentValue = '^0.4.0'; @@ -47,7 +47,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns only one update if grouping', async () => { config.groupName = 'somegroup'; @@ -58,7 +58,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns only one update if automerging', async () => { config.automerge = true; @@ -70,8 +70,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res).toHaveLength(1); + expect(res.updates).toMatchSnapshot(); + expect(res.updates).toHaveLength(1); }); it('returns only one update if automerging major', async () => { config.major = { automerge: true }; @@ -82,7 +82,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns both updates if automerging minor', async () => { config.minor = { automerge: true }; @@ -93,7 +93,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('enforces allowedVersions', async () => { config.currentValue = '0.4.0'; @@ -103,7 +103,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toHaveLength(1); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(1); }); it('skips invalid allowedVersions', async () => { config.currentValue = '0.4.0'; @@ -113,7 +113,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toHaveLength(2); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(2); }); it('returns minor update if separate patches not configured', async () => { config.currentValue = '0.9.0'; @@ -124,10 +124,10 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res.length).toBe(2); - expect(res[0].type).not.toEqual('patch'); - expect(res[1].type).not.toEqual('patch'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates.length).toBe(2); + expect(res.updates[0].type).not.toEqual('patch'); + expect(res.updates[1].type).not.toEqual('patch'); }); it('returns patch update if automerging patch', async () => { config.patch = { @@ -141,8 +141,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].type).toEqual('patch'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].type).toEqual('patch'); }); it('returns minor update if automerging both patch and minor', async () => { config.patch = { @@ -159,8 +159,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].type).toEqual('minor'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].type).toEqual('minor'); }); it('returns patch update if separateMinorPatch', async () => { config.separateMinorPatch = true; @@ -171,7 +171,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns patch minor and major', async () => { config.separateMinorPatch = true; @@ -183,8 +183,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(3); - expect(res).toMatchSnapshot(); + expect(res.updates).toHaveLength(3); + expect(res.updates).toMatchSnapshot(); }); it('disables major release separation (major)', async () => { config.separateMajorMinor = false; @@ -195,7 +195,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('disables major release separation (minor)', async () => { config.separateMajorMinor = false; @@ -206,7 +206,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports minor and major upgrades for ranged versions', async () => { config.currentValue = '~0.4.0'; @@ -216,7 +216,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('ignores pinning for ranges when other upgrade exists', async () => { config.currentValue = '~0.9.0'; @@ -226,7 +226,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades minor ranged versions', async () => { config.currentValue = '~1.0.0'; @@ -236,7 +236,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens minor ranged versions if configured', async () => { config.currentValue = '~1.3.0'; @@ -246,7 +246,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('replaces minor complex ranged versions if configured', async () => { config.currentValue = '~1.2.0 || ~1.3.0'; @@ -256,7 +256,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens major ranged versions if configured', async () => { config.currentValue = '^2.0.0'; @@ -266,7 +266,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('replaces major complex ranged versions if configured', async () => { config.currentValue = '^1.0.0 || ^2.0.0'; @@ -276,7 +276,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('pins minor ranged versions', async () => { config.currentValue = '^1.0.0'; @@ -286,7 +286,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('uses the locked version for pinning', async () => { config.currentValue = '^1.0.0'; @@ -297,7 +297,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('ignores minor ranged versions when not pinning', async () => { config.rangeStrategy = 'replace'; @@ -307,7 +307,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toHaveLength(0); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('upgrades tilde ranges', async () => { config.rangeStrategy = 'pin'; @@ -317,7 +317,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x minor ranges', async () => { config.currentValue = '1.3.x'; @@ -327,7 +327,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades tilde ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -337,7 +337,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x major ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -347,7 +347,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x minor ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -357,7 +357,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades .x complex minor ranges without pinning', async () => { config.rangeStrategy = 'widen'; @@ -367,7 +367,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades shorthand major ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -377,7 +377,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades shorthand minor ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -387,7 +387,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades multiple tilde ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -397,7 +397,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades multiple caret ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -407,7 +407,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports complex ranges', async () => { config.rangeStrategy = 'widen'; @@ -418,8 +418,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(2); - expect(res[0]).toMatchSnapshot(); + expect(res.updates).toHaveLength(2); + expect(res.updates[0]).toMatchSnapshot(); }); it('supports complex major ranges', async () => { config.rangeStrategy = 'widen'; @@ -429,7 +429,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports complex major hyphen ranges', async () => { config.rangeStrategy = 'widen'; @@ -439,7 +439,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens .x OR ranges', async () => { config.rangeStrategy = 'widen'; @@ -449,7 +449,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('widens stanndalone major OR ranges', async () => { config.rangeStrategy = 'widen'; @@ -459,7 +459,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/webpack') .reply(200, webpackJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports complex tilde ranges', async () => { config.rangeStrategy = 'widen'; @@ -469,7 +469,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('returns nothing for greater than ranges', async () => { config.rangeStrategy = 'replace'; @@ -479,7 +479,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toHaveLength(0); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('upgrades less than equal ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -489,7 +489,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -499,7 +499,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than major ranges', async () => { config.rangeStrategy = 'replace'; @@ -509,7 +509,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than equal minor ranges', async () => { config.rangeStrategy = 'replace'; @@ -519,7 +519,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades less than equal major ranges', async () => { config.rangeStrategy = 'replace'; @@ -530,7 +530,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('upgrades major less than equal ranges', async () => { config.rangeStrategy = 'replace'; @@ -541,8 +541,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].newValue).toEqual('<= 1.4.1'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].newValue).toEqual('<= 1.4.1'); }); it('upgrades major less than ranges without pinning', async () => { config.rangeStrategy = 'replace'; @@ -553,8 +553,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].newValue).toEqual('< 2.0.0'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].newValue).toEqual('< 2.0.0'); }); it('upgrades major greater than less than ranges without pinning', async () => { config.rangeStrategy = 'widen'; @@ -565,8 +565,8 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].newValue).toEqual('>= 0.5.0 < 2.0.0'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].newValue).toEqual('>= 0.5.0 < 2.0.0'); }); it('upgrades minor greater than less than ranges without pinning', async () => { config.rangeStrategy = 'widen'; @@ -577,9 +577,9 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].newValue).toEqual('>= 0.5.0 <0.10'); - expect(res[1].newValue).toEqual('>= 0.5.0 <1.5'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].newValue).toEqual('>= 0.5.0 <0.10'); + expect(res.updates[1].newValue).toEqual('>= 0.5.0 <1.5'); }); it('upgrades minor greater than less than equals ranges without pinning', async () => { config.rangeStrategy = 'widen'; @@ -590,9 +590,9 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res[0].newValue).toEqual('>= 0.5.0 <= 0.9.7'); - expect(res[1].newValue).toEqual('>= 0.5.0 <= 1.4.1'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates[0].newValue).toEqual('>= 0.5.0 <= 0.9.7'); + expect(res.updates[1].newValue).toEqual('>= 0.5.0 <= 1.4.1'); }); it('rejects reverse ordered less than greater than', async () => { config.rangeStrategy = 'widen'; @@ -603,7 +603,7 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); + expect(res.updates).toMatchSnapshot(); }); it('supports > latest versions if configured', async () => { config.respectLatest = false; @@ -613,7 +613,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('should ignore unstable versions if the current version is stable', async () => { config.currentValue = '2.5.16'; @@ -622,7 +622,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/vue') .reply(200, vueJson); - expect(await lookup.lookupUpdates(config)).toHaveLength(0); + expect((await lookup.lookupUpdates(config)).updates).toHaveLength(0); }); it('should allow unstable versions if the ignoreUnstable=false', async () => { config.currentValue = '2.5.16'; @@ -633,9 +633,9 @@ describe('manager/npm/lookup', () => { .get('/vue') .reply(200, vueJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res).toHaveLength(1); - expect(res[0].newValue).toEqual('2.5.17-beta.0'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates).toHaveLength(1); + expect(res.updates[0].newValue).toEqual('2.5.17-beta.0'); }); it('should allow unstable versions if the current version is unstable', async () => { config.currentValue = '2.3.0-beta.1'; @@ -645,9 +645,9 @@ describe('manager/npm/lookup', () => { .get('/vue') .reply(200, vueJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); - expect(res).toHaveLength(1); - expect(res[0].newValue).toEqual('2.5.17-beta.0'); + expect(res.updates).toMatchSnapshot(); + expect(res.updates).toHaveLength(1); + expect(res.updates[0].newValue).toEqual('2.5.17-beta.0'); }); it('should treat zero zero tilde ranges as 0.0.x', async () => { config.rangeStrategy = 'replace'; @@ -657,7 +657,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/helmet') .reply(200, helmetJson); - expect(await lookup.lookupUpdates(config)).toEqual([]); + expect((await lookup.lookupUpdates(config)).updates).toEqual([]); }); it('should treat zero zero caret ranges as pinned', async () => { config.rangeStrategy = 'replace'; @@ -667,7 +667,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/helmet') .reply(200, helmetJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('should downgrade from missing versions', async () => { config.currentValue = '1.16.1'; @@ -677,8 +677,8 @@ describe('manager/npm/lookup', () => { .get('/coffeelint') .reply(200, coffeelintJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(1); - expect(res[0]).toMatchSnapshot(); + expect(res.updates).toHaveLength(1); + expect(res.updates[0]).toMatchSnapshot(); }); it('should upgrade to only one major', async () => { config.currentValue = '1.0.0'; @@ -688,7 +688,7 @@ describe('manager/npm/lookup', () => { .get('/webpack') .reply(200, webpackJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(2); + expect(res.updates).toHaveLength(2); }); it('should upgrade to two majors', async () => { config.currentValue = '1.0.0'; @@ -699,7 +699,7 @@ describe('manager/npm/lookup', () => { .get('/webpack') .reply(200, webpackJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(3); + expect(res.updates).toHaveLength(3); }); it('does not jump major unstable', async () => { config.currentValue = '^4.4.0-canary.3'; @@ -710,7 +710,7 @@ describe('manager/npm/lookup', () => { .get('/next') .reply(200, nextJson); const res = await lookup.lookupUpdates(config); - expect(res).toHaveLength(0); + expect(res.updates).toHaveLength(0); }); it('handles prerelease jumps', async () => { config.currentValue = '^2.9.0-rc'; @@ -721,7 +721,7 @@ describe('manager/npm/lookup', () => { .get('/typescript') .reply(200, typescriptJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); + expect(res.updates).toMatchSnapshot(); }); it('supports in-range caret updates', async () => { config.rangeStrategy = 'bump'; @@ -731,7 +731,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports in-range tilde updates', async () => { config.rangeStrategy = 'bump'; @@ -741,7 +741,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('supports in-range gte updates', async () => { config.rangeStrategy = 'bump'; @@ -751,7 +751,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects in-range unsupported operator', async () => { config.rangeStrategy = 'bump'; @@ -761,7 +761,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects non-fully specified in-range updates', async () => { config.rangeStrategy = 'bump'; @@ -771,7 +771,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('rejects complex range in-range updates', async () => { config.rangeStrategy = 'bump'; @@ -781,7 +781,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('replaces non-range in-range updates', async () => { config.depName = 'q'; @@ -792,7 +792,7 @@ describe('manager/npm/lookup', () => { nock('https://registry.npmjs.org') .get('/q') .reply(200, qJson); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles github 404', async () => { config.depName = 'foo'; @@ -802,7 +802,7 @@ describe('manager/npm/lookup', () => { nock('https://pypi.org') .get('/pypi/foo/json') .reply(404); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles pypi 404', async () => { config.depName = 'foo'; @@ -812,7 +812,7 @@ describe('manager/npm/lookup', () => { nock('https://api.github.com') .get('/repos/some/repo/git/refs/tags?per_page=100') .reply(404); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles packagist', async () => { config.depName = 'foo/bar'; @@ -822,14 +822,14 @@ describe('manager/npm/lookup', () => { nock('https://packagist.org') .get('/packages/foo/bar.json') .reply(404); - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles unknown purl', async () => { config.depName = 'foo'; config.purl = 'pkg:typo/some/repo'; config.packageFile = 'package.json'; config.currentValue = '1.0.0'; - expect(await lookup.lookupUpdates(config)).toMatchSnapshot(); + expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); }); it('handles PEP440', async () => { config.manager = 'pip_requirements'; @@ -844,7 +844,7 @@ describe('manager/npm/lookup', () => { .get('/q') .reply(200, qJson); const res = await lookup.lookupUpdates(config); - expect(res).toMatchSnapshot(); + expect(res.updates).toMatchSnapshot(); }); }); });