mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(versioning/loose): Fix suffix comparison (#13745)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
This commit is contained in:
parent
a9920ff8ec
commit
d4bbfe2474
2 changed files with 28 additions and 4 deletions
|
@ -37,6 +37,17 @@ describe('versioning/loose/index', () => {
|
|||
expect(!!loose.isValid(version)).toBe(expected);
|
||||
});
|
||||
|
||||
test.each`
|
||||
a | b | expected
|
||||
${'2.4'} | ${'2.4'} | ${true}
|
||||
${'2.4.0'} | ${'2.4.0'} | ${true}
|
||||
${'2.4.0'} | ${'2.4'} | ${false}
|
||||
${'2.4.1'} | ${'2.4'} | ${false}
|
||||
${'2.4.2'} | ${'2.4.1'} | ${false}
|
||||
`('equals("$a", "$b") === $expected', ({ a, b, expected }) => {
|
||||
expect(loose.equals(a, b)).toBe(expected);
|
||||
});
|
||||
|
||||
test.each`
|
||||
a | b | expected
|
||||
${'2.4.0'} | ${'2.4'} | ${true}
|
||||
|
@ -44,6 +55,10 @@ describe('versioning/loose/index', () => {
|
|||
${'2.4.beta'} | ${'2.4.alpha'} | ${true}
|
||||
${'1.9'} | ${'2'} | ${false}
|
||||
${'1.9'} | ${'1.9.1'} | ${false}
|
||||
${'2.4'} | ${'2.4.beta'} | ${true}
|
||||
${'2.4.0'} | ${'2.4.beta'} | ${true}
|
||||
${'2.4.beta'} | ${'2.4'} | ${false}
|
||||
${'2.4.beta'} | ${'2.4.0'} | ${false}
|
||||
`('isGreaterThan("$a", "$b") === $expected', ({ a, b, expected }) => {
|
||||
expect(loose.isGreaterThan(a, b)).toBe(expected);
|
||||
});
|
||||
|
|
|
@ -50,12 +50,21 @@ class LooseVersioningApi extends GenericVersioningApi {
|
|||
return part1 - part2;
|
||||
}
|
||||
}
|
||||
// istanbul ignore if
|
||||
if (!(parsed1.suffix && parsed2.suffix)) {
|
||||
|
||||
if (parsed1.suffix && parsed2.suffix) {
|
||||
return parsed1.suffix.localeCompare(parsed2.suffix);
|
||||
}
|
||||
|
||||
if (parsed1.suffix) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (parsed2.suffix) {
|
||||
return 1;
|
||||
}
|
||||
// equals
|
||||
return parsed1.suffix.localeCompare(parsed2.suffix);
|
||||
|
||||
// istanbul ignore next
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue