-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Fix skip-install for stable latest releases
- Loading branch information
1 parent
1d27f37
commit 2f4658b
Showing
2 changed files
with
61 additions
and
6 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
code/core/src/common/js-package-manager/JsPackageManager.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import { JsPackageManager } from './JsPackageManager'; | ||
|
||
vi.mock('../versions', () => ({ | ||
default: { | ||
'@storybook/react': '8.3.0', | ||
}, | ||
})); | ||
|
||
describe('JsPackageManager', () => { | ||
let jsPackageManager: JsPackageManager; | ||
let mockLatestVersion: ReturnType<typeof vi.fn>; | ||
let mockStorybookPackagesVersions: Record<string, string>; | ||
|
||
beforeEach(() => { | ||
mockLatestVersion = vi.fn(); | ||
mockStorybookPackagesVersions = { | ||
'@storybook/react': '8.3.0', | ||
}; | ||
|
||
// @ts-expect-error Ignore abstract class error | ||
jsPackageManager = new JsPackageManager(); | ||
jsPackageManager.latestVersion = mockLatestVersion; | ||
(global as any).storybookPackagesVersions = mockStorybookPackagesVersions; | ||
|
||
vi.clearAllMocks(); | ||
}); | ||
|
||
describe('getVersionedPackages method', () => { | ||
it('should return the latest stable release version when current version is the latest stable release', async () => { | ||
mockLatestVersion.mockResolvedValue('8.3.0'); | ||
|
||
const result = await jsPackageManager.getVersionedPackages(['@storybook/react']); | ||
|
||
expect(result).toEqual(['@storybook/react@^8.3.0']); | ||
}); | ||
|
||
it('should return the current version when it is not the latest stable release', async () => { | ||
mockLatestVersion.mockResolvedValue('8.3.1'); | ||
|
||
const result = await jsPackageManager.getVersionedPackages(['@storybook/react']); | ||
|
||
expect(result).toEqual(['@storybook/[email protected]']); | ||
}); | ||
|
||
it('should return the latest stable release version when there is no current version', async () => { | ||
mockLatestVersion.mockResolvedValue('2.0.0'); | ||
|
||
const result = await jsPackageManager.getVersionedPackages(['@storybook/new-addon@^8.3.0']); | ||
|
||
expect(result).toEqual(['@storybook/new-addon@^2.0.0']); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters