From 9b474844e85cce916370693cc24f53339a695570 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Jul 2019 10:37:35 +0200 Subject: Add CLI plugins tests --- server/tests/fixtures/peertube-plugin-test/main.js | 39 ++++++++++++++++++++++ .../fixtures/peertube-plugin-test/package.json | 19 +++++++++++ 2 files changed, 58 insertions(+) create mode 100644 server/tests/fixtures/peertube-plugin-test/main.js create mode 100644 server/tests/fixtures/peertube-plugin-test/package.json (limited to 'server/tests/fixtures/peertube-plugin-test') diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js new file mode 100644 index 000000000..fae0ef948 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test/main.js @@ -0,0 +1,39 @@ +async function register ({ registerHook, registerSetting, settingsManager, storageManager }) { + const defaultAdmin = 'PeerTube admin' + + registerHook({ + target: 'action:application.listening', + handler: () => displayHelloWorld(settingsManager, defaultAdmin) + }) + + registerSetting({ + name: 'admin-name', + label: 'Admin name', + type: 'input', + default: defaultAdmin + }) + + const value = await storageManager.getData('toto') + console.log(value) + console.log(value.coucou) + + await storageManager.storeData('toto', { coucou: 'hello' + new Date() }) +} + +async function unregister () { + return +} + +module.exports = { + register, + unregister +} + +// ############################################################################ + +async function displayHelloWorld (settingsManager, defaultAdmin) { + let value = await settingsManager.getSetting('admin-name') + if (!value) value = defaultAdmin + + console.log('hello world ' + value) +} diff --git a/server/tests/fixtures/peertube-plugin-test/package.json b/server/tests/fixtures/peertube-plugin-test/package.json new file mode 100644 index 000000000..9d6fe5c90 --- /dev/null +++ b/server/tests/fixtures/peertube-plugin-test/package.json @@ -0,0 +1,19 @@ +{ + "name": "peertube-plugin-test", + "version": "0.0.1", + "description": "Plugin test", + "engine": { + "peertube": ">=1.3.0" + }, + "keywords": [ + "peertube", + "plugin" + ], + "homepage": "https://github.com/Chocobozzz/PeerTube", + "author": "Chocobozzz", + "bugs": "https://github.com/Chocobozzz/PeerTube/issues", + "library": "./main.js", + "staticDirs": {}, + "css": [], + "clientScripts": [] +} -- cgit v1.2.3