import { Mock } from 'ts-mockery'; import { SemVer, versionMatch, Versions } from '../../../src/utils/helpers/version'; import { Empty } from '../../../src/utils/utils'; describe('version', () => { describe('versionMatch', () => { it.each([ [undefined, Mock.all(), false], [null, Mock.all(), false], ['' as Empty, Mock.all(), false], [[], Mock.all(), false], ['2.8.3' as SemVer, Mock.all(), true], ['2.8.3' as SemVer, Mock.of({ minVersion: '2.0.0' }), true], ['2.0.0' as SemVer, Mock.of({ minVersion: '2.0.0' }), true], ['1.8.0' as SemVer, Mock.of({ maxVersion: '1.8.0' }), true], ['1.7.1' as SemVer, Mock.of({ maxVersion: '1.8.0' }), true], ['1.7.3' as SemVer, Mock.of({ minVersion: '1.7.0', maxVersion: '1.8.0' }), true], ['1.8.3' as SemVer, Mock.of({ minVersion: '2.0.0' }), false], ['1.8.3' as SemVer, Mock.of({ maxVersion: '1.8.0' }), false], ['1.8.3' as SemVer, Mock.of({ 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); }); }); });