2019-07-22 11:12:40 +00:00
|
|
|
import semver from '../../lib/versioning/semver';
|
2018-04-10 03:20:46 +00:00
|
|
|
|
2018-06-03 15:00:58 +00:00
|
|
|
describe('semver.isValid(input)', () => {
|
2018-04-10 04:02:48 +00:00
|
|
|
it('should return null for irregular versions', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('17.04.0')).toBeFalsy();
|
2018-04-10 04:02:48 +00:00
|
|
|
});
|
2018-04-10 03:20:46 +00:00
|
|
|
it('should support simple semver', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('1.2.3')).toBeTruthy();
|
2018-04-10 03:20:46 +00:00
|
|
|
});
|
|
|
|
it('should support semver with dash', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('1.2.3-foo')).toBeTruthy();
|
2018-04-10 03:20:46 +00:00
|
|
|
});
|
|
|
|
it('should reject semver without dash', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('1.2.3foo')).toBeFalsy();
|
2018-04-10 03:20:46 +00:00
|
|
|
});
|
2019-01-07 04:49:47 +00:00
|
|
|
it('should reject ranges', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('~1.2.3')).toBeFalsy();
|
|
|
|
expect(semver.isValid('^1.2.3')).toBeFalsy();
|
|
|
|
expect(semver.isValid('>1.2.3')).toBeFalsy();
|
2018-04-10 03:20:46 +00:00
|
|
|
});
|
|
|
|
it('should reject github repositories', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isValid('renovatebot/renovate')).toBeFalsy();
|
|
|
|
expect(semver.isValid('renovatebot/renovate#master')).toBeFalsy();
|
2018-04-10 03:20:46 +00:00
|
|
|
expect(
|
2019-04-15 11:39:49 +00:00
|
|
|
semver.isValid('https://github.com/renovatebot/renovate.git')
|
|
|
|
).toBeFalsy();
|
2018-04-10 03:20:46 +00:00
|
|
|
});
|
|
|
|
});
|
2018-06-05 12:52:40 +00:00
|
|
|
describe('semver.isSingleVersion()', () => {
|
|
|
|
it('returns true if naked version', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isSingleVersion('1.2.3')).toBeTruthy();
|
|
|
|
expect(semver.isSingleVersion('1.2.3-alpha.1')).toBeTruthy();
|
2018-06-05 12:52:40 +00:00
|
|
|
});
|
2019-01-07 04:49:47 +00:00
|
|
|
it('returns false if equals', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isSingleVersion('=1.2.3')).toBeFalsy();
|
|
|
|
expect(semver.isSingleVersion('= 1.2.3')).toBeFalsy();
|
2018-06-05 12:52:40 +00:00
|
|
|
});
|
|
|
|
it('returns false when not version', () => {
|
2019-04-15 11:39:49 +00:00
|
|
|
expect(semver.isSingleVersion('1.x')).toBeFalsy();
|
2018-06-05 12:52:40 +00:00
|
|
|
});
|
|
|
|
});
|
2018-06-04 04:03:21 +00:00
|
|
|
describe('semver.getNewValue()', () => {
|
2019-01-07 04:49:47 +00:00
|
|
|
it('uses toVersion', () => {
|
2020-01-16 12:43:58 +00:00
|
|
|
expect(
|
|
|
|
semver.getNewValue({
|
|
|
|
currentValue: '=1.0.0',
|
|
|
|
rangeStrategy: 'bump',
|
|
|
|
fromVersion: '1.0.0',
|
|
|
|
toVersion: '1.1.0',
|
|
|
|
})
|
|
|
|
).toEqual('1.1.0');
|
2018-06-03 19:16:57 +00:00
|
|
|
});
|
|
|
|
});
|