aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/helpers')
-rw-r--r--server/tests/helpers/index.ts1
-rw-r--r--server/tests/helpers/validator.ts32
2 files changed, 33 insertions, 0 deletions
diff --git a/server/tests/helpers/index.ts b/server/tests/helpers/index.ts
index 1f0e3098a..1b5c6d15b 100644
--- a/server/tests/helpers/index.ts
+++ b/server/tests/helpers/index.ts
@@ -5,3 +5,4 @@ import './dns'
5import './image' 5import './image'
6import './markdown' 6import './markdown'
7import './request' 7import './request'
8import './validator'
diff --git a/server/tests/helpers/validator.ts b/server/tests/helpers/validator.ts
new file mode 100644
index 000000000..f40a3aaae
--- /dev/null
+++ b/server/tests/helpers/validator.ts
@@ -0,0 +1,32 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import { expect } from 'chai'
4import { isPluginStableOrUnstableVersionValid, isPluginStableVersionValid } from '@server/helpers/custom-validators/plugins'
5
6describe('Validators', function () {
7
8 it('Should correctly check stable plugin versions', async function () {
9 expect(isPluginStableVersionValid('3.4.0')).to.be.true
10 expect(isPluginStableVersionValid('0.4.0')).to.be.true
11 expect(isPluginStableVersionValid('0.1.0')).to.be.true
12
13 expect(isPluginStableVersionValid('0.1.0-beta-1')).to.be.false
14 expect(isPluginStableVersionValid('hello')).to.be.false
15 expect(isPluginStableVersionValid('0.x.a')).to.be.false
16 })
17
18 it('Should correctly check unstable plugin versions', async function () {
19 expect(isPluginStableOrUnstableVersionValid('3.4.0')).to.be.true
20 expect(isPluginStableOrUnstableVersionValid('0.4.0')).to.be.true
21 expect(isPluginStableOrUnstableVersionValid('0.1.0')).to.be.true
22
23 expect(isPluginStableOrUnstableVersionValid('0.1.0-beta.1')).to.be.true
24 expect(isPluginStableOrUnstableVersionValid('0.1.0-alpha.45')).to.be.true
25 expect(isPluginStableOrUnstableVersionValid('0.1.0-rc.45')).to.be.true
26
27 expect(isPluginStableOrUnstableVersionValid('hello')).to.be.false
28 expect(isPluginStableOrUnstableVersionValid('0.x.a')).to.be.false
29 expect(isPluginStableOrUnstableVersionValid('0.1.0-rc-45')).to.be.false
30 expect(isPluginStableOrUnstableVersionValid('0.1.0-rc.45d')).to.be.false
31 })
32})