diff options
author | Chocobozzz <me@florianbigard.com> | 2023-01-19 13:53:24 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-01-19 13:54:53 +0100 |
commit | 6e06694fd6acab185432bccf57bd5c9c3b68f218 (patch) | |
tree | 57fb4069ff366f0b57c138acf9e3d91397d2bc50 /server/tests/helpers/version.ts | |
parent | f008e9f3f34ed1724afd5e071c39ed931741acbc (diff) | |
download | PeerTube-6e06694fd6acab185432bccf57bd5c9c3b68f218.tar.gz PeerTube-6e06694fd6acab185432bccf57bd5c9c3b68f218.tar.zst PeerTube-6e06694fd6acab185432bccf57bd5c9c3b68f218.zip |
Fix semver comparison
Diffstat (limited to 'server/tests/helpers/version.ts')
-rw-r--r-- | server/tests/helpers/version.ts | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/server/tests/helpers/version.ts b/server/tests/helpers/version.ts new file mode 100644 index 000000000..7d5600715 --- /dev/null +++ b/server/tests/helpers/version.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { compareSemVer } from '@shared/core-utils' | ||
5 | |||
6 | describe('Version', function () { | ||
7 | |||
8 | it('Should correctly compare two stable versions', async function () { | ||
9 | expect(compareSemVer('3.4.0', '3.5.0')).to.be.below(0) | ||
10 | expect(compareSemVer('3.5.0', '3.4.0')).to.be.above(0) | ||
11 | |||
12 | expect(compareSemVer('3.4.0', '4.1.0')).to.be.below(0) | ||
13 | expect(compareSemVer('4.1.0', '3.4.0')).to.be.above(0) | ||
14 | |||
15 | expect(compareSemVer('3.4.0', '3.4.1')).to.be.below(0) | ||
16 | expect(compareSemVer('3.4.1', '3.4.0')).to.be.above(0) | ||
17 | }) | ||
18 | |||
19 | it('Should correctly compare two unstable version', async function () { | ||
20 | expect(compareSemVer('3.4.0-alpha', '3.4.0-beta.1')).to.be.below(0) | ||
21 | expect(compareSemVer('3.4.0-alpha.1', '3.4.0-beta.1')).to.be.below(0) | ||
22 | expect(compareSemVer('3.4.0-beta.1', '3.4.0-beta.2')).to.be.below(0) | ||
23 | expect(compareSemVer('3.4.0-beta.1', '3.5.0-alpha.1')).to.be.below(0) | ||
24 | }) | ||
25 | |||
26 | it('Should correctly compare a stable and unstable versions', async function () { | ||
27 | expect(compareSemVer('3.4.0', '3.4.1-beta.1')).to.be.below(0) | ||
28 | expect(compareSemVer('3.4.0-beta.1', '3.4.0-beta.2')).to.be.below(0) | ||
29 | expect(compareSemVer('3.4.0-beta.1', '3.4.0')).to.be.below(0) | ||
30 | }) | ||
31 | }) | ||