diff options
Diffstat (limited to 'packages/tests/src/server-helpers/version.ts')
-rw-r--r-- | packages/tests/src/server-helpers/version.ts | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/tests/src/server-helpers/version.ts b/packages/tests/src/server-helpers/version.ts new file mode 100644 index 000000000..76892d1e7 --- /dev/null +++ b/packages/tests/src/server-helpers/version.ts | |||
@@ -0,0 +1,36 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import { expect } from 'chai' | ||
4 | import { compareSemVer } from '@peertube/peertube-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 | expect(compareSemVer('3.4.0-alpha.1', '3.4.0-nightly.4')).to.be.below(0) | ||
26 | expect(compareSemVer('3.4.0-nightly.3', '3.4.0-nightly.4')).to.be.below(0) | ||
27 | expect(compareSemVer('3.3.0-nightly.5', '3.4.0-nightly.4')).to.be.below(0) | ||
28 | }) | ||
29 | |||
30 | it('Should correctly compare a stable and unstable versions', async function () { | ||
31 | expect(compareSemVer('3.4.0', '3.4.1-beta.1')).to.be.below(0) | ||
32 | expect(compareSemVer('3.4.0-beta.1', '3.4.0-beta.2')).to.be.below(0) | ||
33 | expect(compareSemVer('3.4.0-beta.1', '3.4.0')).to.be.below(0) | ||
34 | expect(compareSemVer('3.4.0-nightly.4', '3.4.0')).to.be.below(0) | ||
35 | }) | ||
36 | }) | ||