mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
131 lines
4.6 KiB
TypeScript
131 lines
4.6 KiB
TypeScript
import docker from '../../lib/versioning/docker';
|
|
import semver from '../../lib/versioning/semver';
|
|
|
|
describe('docker.', () => {
|
|
describe('isValid(version)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.isValid(null)).toBeNull();
|
|
expect(docker.isValid('1.2.3')).toBe('1.2.3');
|
|
expect(docker.isValid('18.04')).toBe('18.04');
|
|
expect(docker.isValid('10.1')).toBe('10.1');
|
|
expect(docker.isValid('3')).toBe('3');
|
|
expect(docker.isValid('foo')).toBeNull();
|
|
});
|
|
});
|
|
describe('getMajor(version)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.getMajor('1.2.3')).toBe(1);
|
|
expect(docker.getMajor('18.04')).toBe(18);
|
|
expect(docker.getMajor('10.1')).toBe(10);
|
|
expect(docker.getMajor('3')).toBe(3);
|
|
expect(docker.getMajor('foo')).toBeNull();
|
|
});
|
|
});
|
|
describe('getMinor(version)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.getMinor('1.2.3')).toBe(2);
|
|
expect(docker.getMinor('18.04')).toBe(4);
|
|
expect(docker.getMinor('10.1')).toBe(1);
|
|
expect(docker.getMinor('3')).toBeNull();
|
|
expect(docker.getMinor('foo')).toBeNull();
|
|
});
|
|
});
|
|
describe('getPatch(version)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.getPatch('1.2.3')).toBe(3);
|
|
expect(docker.getPatch('18.04')).toBeNull();
|
|
expect(docker.getPatch('10.1')).toBeNull();
|
|
expect(docker.getPatch('3')).toBeNull();
|
|
expect(docker.getPatch('foo')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('isGreaterThan(version, other)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.isGreaterThan('1.2.3', '1.2')).toBe(false);
|
|
expect(docker.isGreaterThan('18.04', '18.1')).toBe(true);
|
|
expect(docker.isGreaterThan('10.1', '10.1.2')).toBe(true);
|
|
expect(docker.isGreaterThan('3', '2')).toBe(true);
|
|
expect(docker.isGreaterThan('1.2.3', '1.2.3')).toBe(false);
|
|
});
|
|
});
|
|
describe('isLessThanRange(version, range)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.isLessThanRange('1.2.3', '2.0')).toBe(true);
|
|
expect(docker.isLessThanRange('18.04', '18.1')).toBe(false);
|
|
expect(docker.isLessThanRange('10.1', '10.0.4')).toBe(false);
|
|
expect(docker.isLessThanRange('3', '4.0')).toBe(true);
|
|
expect(docker.isLessThanRange('1.2', '1.3.4')).toBe(true);
|
|
});
|
|
});
|
|
describe('equals(version, other)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.equals('1.2.3', '1.2.3')).toBe(true);
|
|
expect(docker.equals('18.04', '18.4')).toBe(true);
|
|
expect(docker.equals('10.0', '10.0.4')).toBe(false);
|
|
expect(docker.equals('3', '4.0')).toBe(false);
|
|
expect(docker.equals('1.2', '1.2.3')).toBe(false);
|
|
});
|
|
});
|
|
describe('equals(version, other)', () => {
|
|
it('should support all versions length', () => {
|
|
expect(docker.equals('1.2.3', '1.2.3')).toBe(true);
|
|
expect(docker.equals('18.04', '18.4')).toBe(true);
|
|
expect(docker.equals('10.0', '10.0.4')).toBe(false);
|
|
expect(docker.equals('3', '4.0')).toBe(false);
|
|
expect(docker.equals('1.2', '1.2.3')).toBe(false);
|
|
});
|
|
});
|
|
describe('maxSatisfyingVersion(versions, range)', () => {
|
|
it('should support all versions length', () => {
|
|
[docker.minSatisfyingVersion, docker.maxSatisfyingVersion].forEach(
|
|
max => {
|
|
const versions = [
|
|
'0.9.8',
|
|
'1.1.1',
|
|
'1.1',
|
|
'1.2.3',
|
|
'1.2',
|
|
'1',
|
|
'2.2.2',
|
|
'2.2',
|
|
'2',
|
|
];
|
|
// returns range if found
|
|
expect(max(versions, '1.2.3')).toBe('1.2.3');
|
|
expect(max(versions, '1.2')).toBe('1.2');
|
|
expect(max(versions, '1')).toBe('1');
|
|
// return null if not found
|
|
expect(max(versions, '1.3')).toBeNull();
|
|
expect(max(versions, '0.9')).toBeNull();
|
|
}
|
|
);
|
|
});
|
|
});
|
|
describe('sortVersions(v1, v2)', () => {
|
|
it('behaves like semver.sortVersions', () => {
|
|
[
|
|
['1.1.1', '1.2.3'],
|
|
['1.2.3', '1.3.4'],
|
|
['2.0.1', '1.2.3'],
|
|
['1.2.3', '0.9.5'],
|
|
].forEach(pair => {
|
|
expect(docker.sortVersions(pair[0], pair[1])).toBe(
|
|
semver.sortVersions(pair[0], pair[1])
|
|
);
|
|
});
|
|
});
|
|
});
|
|
describe('getNewValue(', () => {
|
|
it('returns toVersion', () => {
|
|
expect(
|
|
docker.getNewValue({
|
|
currentValue: null,
|
|
rangeStrategy: null,
|
|
fromVersion: null,
|
|
toVersion: '1.2.3',
|
|
})
|
|
).toBe('1.2.3');
|
|
});
|
|
});
|
|
});
|