|
| 1 | +import { getUsableVersions } from "./get-usable"; |
| 2 | +import { Project } from "../project/projects"; |
| 3 | +import { getIndividualVersionsForProject } from "../versions/get-versions-for-project"; |
| 4 | + |
| 5 | +// Mock the dependencies |
| 6 | +jest.mock('../versions/get-versions-for-project'); |
| 7 | +const mockGetVersions = getIndividualVersionsForProject as jest.Mock; |
| 8 | + |
| 9 | +describe('getUsableVersions for magento-open-source', () => { |
| 10 | + const project: Project = "magento-open-source"; |
| 11 | + |
| 12 | + beforeEach(() => { |
| 13 | + mockGetVersions.mockReset(); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should return an array of versions', () => { |
| 17 | + mockGetVersions.mockReturnValue({ |
| 18 | + 'magento/project-community-edition:2.4.6': { composer: '2.2.0' } |
| 19 | + }); |
| 20 | + expect(Array.isArray(getUsableVersions(project))).toBe(true); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should filter out versions with composer < 2.0.0', () => { |
| 24 | + mockGetVersions.mockReturnValue({ |
| 25 | + 'magento/project-community-edition:2.4.5': { composer: '1.9.0' }, |
| 26 | + 'magento/project-community-edition:2.4.6': { composer: '2.2.0' } |
| 27 | + }); |
| 28 | + |
| 29 | + const versions = getUsableVersions(project); |
| 30 | + expect(versions).not.toContain('magento/project-community-edition:2.4.5'); |
| 31 | + expect(versions).toContain('magento/project-community-edition:2.4.6'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should handle composer version equal to 2.0.0', () => { |
| 35 | + mockGetVersions.mockReturnValue({ |
| 36 | + 'magento/project-community-edition:2.4.6': { composer: '2.0.0' } |
| 37 | + }); |
| 38 | + |
| 39 | + const versions = getUsableVersions(project); |
| 40 | + expect(versions).toContain('magento/project-community-edition:2.4.6'); |
| 41 | + }); |
| 42 | +}); |
0 commit comments