2021-03-06 11:58:29 +03:00
|
|
|
import { Mock } from 'ts-mockery';
|
2023-02-18 12:40:37 +03:00
|
|
|
import type { SemVer, Versions } from '../../../src/utils/helpers/version';
|
|
|
|
import { versionMatch } from '../../../src/utils/helpers/version';
|
|
|
|
import type { Empty } from '../../../src/utils/utils';
|
2020-03-29 19:55:41 +03:00
|
|
|
|
|
|
|
describe('version', () => {
|
|
|
|
describe('versionMatch', () => {
|
|
|
|
it.each([
|
2022-03-26 14:17:42 +03:00
|
|
|
[undefined, Mock.all<Versions>(), false],
|
|
|
|
[null, Mock.all<Versions>(), false],
|
|
|
|
['' as Empty, Mock.all<Versions>(), false],
|
|
|
|
[[], Mock.all<Versions>(), false],
|
|
|
|
['2.8.3' as SemVer, Mock.all<Versions>(), true],
|
|
|
|
['2.8.3' as SemVer, Mock.of<Versions>({ minVersion: '2.0.0' }), true],
|
|
|
|
['2.0.0' as SemVer, Mock.of<Versions>({ minVersion: '2.0.0' }), true],
|
|
|
|
['1.8.0' as SemVer, Mock.of<Versions>({ maxVersion: '1.8.0' }), true],
|
|
|
|
['1.7.1' as SemVer, Mock.of<Versions>({ maxVersion: '1.8.0' }), true],
|
|
|
|
['1.7.3' as SemVer, Mock.of<Versions>({ minVersion: '1.7.0', maxVersion: '1.8.0' }), true],
|
|
|
|
['1.8.3' as SemVer, Mock.of<Versions>({ minVersion: '2.0.0' }), false],
|
|
|
|
['1.8.3' as SemVer, Mock.of<Versions>({ maxVersion: '1.8.0' }), false],
|
|
|
|
['1.8.3' as SemVer, Mock.of<Versions>({ minVersion: '1.7.0', maxVersion: '1.8.0' }), false],
|
2020-03-29 19:55:41 +03:00
|
|
|
])('properly matches versions based on what is provided', (version, versionConstraints, expected) => {
|
|
|
|
expect(versionMatch(version, versionConstraints)).toEqual(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|