From 5c97a7789604fe4098d742334ab2c2b5d77de92d Mon Sep 17 00:00:00 2001 From: Andre Wanlin <67169551+awanlin@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:45:12 -0500 Subject: [PATCH] Got test working Signed-off-by: Andre Wanlin <67169551+awanlin@users.noreply.github.com> --- .../cli/src/commands/versions/bump.test.ts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/packages/cli/src/commands/versions/bump.test.ts b/packages/cli/src/commands/versions/bump.test.ts index bb70b4c54e..84019b55ee 100644 --- a/packages/cli/src/commands/versions/bump.test.ts +++ b/packages/cli/src/commands/versions/bump.test.ts @@ -29,6 +29,7 @@ import { YarnInfoInspectData } from '../../lib/versioning/packages'; import { setupServer } from 'msw/node'; import { rest } from 'msw'; import { NotFoundError } from '@backstage/errors'; +import { Lockfile } from '../../lib/versioning/Lockfile'; // Remove log coloring to simplify log matching jest.mock('chalk', () => ({ @@ -795,6 +796,33 @@ describe('bump', () => { }); it('should log duplicates', async () => { + jest.spyOn(Lockfile.prototype, 'analyze').mockReturnValue({ + invalidRanges: [], + newVersions: [], + newRanges: [ + { + name: 'first-duplicate', + oldRange: 'first-duplicate', + newRange: 'first-duplicate', + oldVersion: '1.0.0', + newVersion: '2.0.0', + }, + { + name: 'second-duplicate', + oldRange: 'second-duplicate', + newRange: 'second-duplicate', + oldVersion: '1.0.0', + newVersion: '2.0.0', + }, + { + name: 'third-duplicate', + oldRange: 'third-duplicate', + newRange: 'third-duplicate', + oldVersion: '1.0.0', + newVersion: '2.0.0', + }, + ], + }); mockFs({ '/yarn.lock': lockfileMock, '/package.json': JSON.stringify({ @@ -854,6 +882,7 @@ describe('bump', () => { ' https://github.com/backstage/backstage/blob/master/packages/theme/CHANGELOG.md', 'Version bump complete!', 'The following packages have duplicates but have been allowed:', + 'first-duplicate, second-duplicate, third-duplicate', ]); }); });