mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	feat: move plugin tests to separate file
This commit is contained in:
		
							
								
								
									
										21
									
								
								test/plugins-installed.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								test/plugins-installed.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | 'use strict'; | ||||||
|  |  | ||||||
|  | const path = require('path'); | ||||||
|  | const fs = require('fs'); | ||||||
|  | const db = require('./mocks/databasemock'); | ||||||
|  |  | ||||||
|  | const installedPlugins = fs.readdirSync(path.join(__dirname, '../node_modules')) | ||||||
|  | 	.filter(p => p.startsWith('nodebb-')); | ||||||
|  |  | ||||||
|  | describe('Installed Plugins', function () { | ||||||
|  | 	installedPlugins.forEach((plugin) => { | ||||||
|  | 		const pathToTests = path.join(__dirname, '../node_modules', plugin, 'test'); | ||||||
|  | 		try { | ||||||
|  | 			require(pathToTests); | ||||||
|  | 		} catch (err) { | ||||||
|  | 			if (err.code !== 'MODULE_NOT_FOUND') { | ||||||
|  | 				console.log(err.stack); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	}); | ||||||
|  | }); | ||||||
| @@ -11,20 +11,6 @@ var db = require('./mocks/databasemock'); | |||||||
| var plugins = require('../src/plugins'); | var plugins = require('../src/plugins'); | ||||||
|  |  | ||||||
| describe('Plugins', function () { | describe('Plugins', function () { | ||||||
| 	describe('Installed Plugins', async function () { |  | ||||||
| 		const installedPlugins = await plugins.showInstalled(); |  | ||||||
| 		installedPlugins.forEach((plugin) => { |  | ||||||
| 			const pathToTests = path.join(__dirname, '../node_modules', plugin.id, 'test'); |  | ||||||
| 			try { |  | ||||||
| 				require(pathToTests); |  | ||||||
| 			} catch (err) { |  | ||||||
| 				if (err.code !== 'MODULE_NOT_FOUND') { |  | ||||||
| 					console.log(err.stack); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		}); |  | ||||||
| 	}); |  | ||||||
|  |  | ||||||
| 	it('should load plugin data', function (done) { | 	it('should load plugin data', function (done) { | ||||||
| 		var pluginId = 'nodebb-plugin-markdown'; | 		var pluginId = 'nodebb-plugin-markdown'; | ||||||
| 		plugins.loadPlugin(path.join(nconf.get('base_dir'), 'node_modules/' + pluginId), function (err) { | 		plugins.loadPlugin(path.join(nconf.get('base_dir'), 'node_modules/' + pluginId), function (err) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user