From ff91b644fb1b063d0a8eff7492beb1a9bf7e4ce1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Nov 2022 14:49:50 +0100 Subject: Add ability to install alpha/beta/rc plugin --- server/tests/helpers/index.ts | 1 + server/tests/helpers/validator.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 server/tests/helpers/validator.ts (limited to 'server/tests/helpers') 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' import './image' import './markdown' import './request' +import './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 @@ +/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ + +import { expect } from 'chai' +import { isPluginStableOrUnstableVersionValid, isPluginStableVersionValid } from '@server/helpers/custom-validators/plugins' + +describe('Validators', function () { + + it('Should correctly check stable plugin versions', async function () { + expect(isPluginStableVersionValid('3.4.0')).to.be.true + expect(isPluginStableVersionValid('0.4.0')).to.be.true + expect(isPluginStableVersionValid('0.1.0')).to.be.true + + expect(isPluginStableVersionValid('0.1.0-beta-1')).to.be.false + expect(isPluginStableVersionValid('hello')).to.be.false + expect(isPluginStableVersionValid('0.x.a')).to.be.false + }) + + it('Should correctly check unstable plugin versions', async function () { + expect(isPluginStableOrUnstableVersionValid('3.4.0')).to.be.true + expect(isPluginStableOrUnstableVersionValid('0.4.0')).to.be.true + expect(isPluginStableOrUnstableVersionValid('0.1.0')).to.be.true + + expect(isPluginStableOrUnstableVersionValid('0.1.0-beta.1')).to.be.true + expect(isPluginStableOrUnstableVersionValid('0.1.0-alpha.45')).to.be.true + expect(isPluginStableOrUnstableVersionValid('0.1.0-rc.45')).to.be.true + + expect(isPluginStableOrUnstableVersionValid('hello')).to.be.false + expect(isPluginStableOrUnstableVersionValid('0.x.a')).to.be.false + expect(isPluginStableOrUnstableVersionValid('0.1.0-rc-45')).to.be.false + expect(isPluginStableOrUnstableVersionValid('0.1.0-rc.45d')).to.be.false + }) +}) -- cgit v1.2.3