import { fromPartial } from '@total-typescript/shoehorn'; import type { Empty, SemVer, Versions } from '../../../src/utils/helpers/version'; import { versionMatch } from '../../../src/utils/helpers/version'; describe('version', () => { describe('versionMatch', () => { it.each([ [undefined, fromPartial({}), false], [null, fromPartial({}), false], ['' as Empty, fromPartial({}), false], [[], fromPartial({}), false], ['2.8.3' as SemVer, fromPartial({}), true], ['2.8.3' as SemVer, fromPartial({ minVersion: '2.0.0' }), true], ['2.0.0' as SemVer, fromPartial({ minVersion: '2.0.0' }), true], ['1.8.0' as SemVer, fromPartial({ maxVersion: '1.8.0' }), true], ['1.7.1' as SemVer, fromPartial({ maxVersion: '1.8.0' }), true], ['1.7.3' as SemVer, fromPartial({ minVersion: '1.7.0', maxVersion: '1.8.0' }), true], ['1.8.3' as SemVer, fromPartial({ minVersion: '2.0.0' }), false], ['1.8.3' as SemVer, fromPartial({ maxVersion: '1.8.0' }), false], ['1.8.3' as SemVer, fromPartial({ minVersion: '1.7.0', maxVersion: '1.8.0' }), false], ])('properly matches versions based on what is provided', (version, versionConstraints, expected) => { expect(versionMatch(version, versionConstraints)).toEqual(expected); }); }); });