mirror of
https://github.com/strapi/strapi.git
synced 2025-12-26 14:44:31 +00:00
Add tests
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
3568beaa28
commit
4cfdbeed19
23
packages/core/admin/utils/__tests__/get-plugins-path.test.js
Normal file
23
packages/core/admin/utils/__tests__/get-plugins-path.test.js
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const getPluginsPath = require('../get-plugins-path');
|
||||
|
||||
describe('getPluginsPath', () => {
|
||||
test('should return an array of directories that contains an admin/src/index.js file', () => {
|
||||
const results = getPluginsPath();
|
||||
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
// Test that the content-type-builder is included
|
||||
expect(results.findIndex(p => p.includes('/core/content-type-builder/admin'))).not.toEqual(-1);
|
||||
// Test that the upload is included
|
||||
expect(results.findIndex(p => p.includes('/core/upload/admin'))).not.toEqual(-1);
|
||||
// Test that the documentation is included
|
||||
expect(results.findIndex(p => p.includes('/plugins/documentation/admin'))).not.toEqual(-1);
|
||||
// Test that the CM is not included
|
||||
expect(results.findIndex(p => p.includes('/core/content-manager/admin'))).toEqual(-1);
|
||||
// Test that the admin package is not included
|
||||
expect(results.findIndex(p => p.includes('/core/admin/admin'))).toEqual(-1);
|
||||
// Test that the helper-plugin package is not included
|
||||
expect(results.findIndex(p => p.includes('helper-plugin'))).toEqual(-1);
|
||||
});
|
||||
});
|
||||
@ -6,13 +6,14 @@ const fs = require('fs-extra');
|
||||
const glob = require('glob');
|
||||
|
||||
const getPluginsPath = () => {
|
||||
const rootPath = join('..', '..', '..', 'packages');
|
||||
const rootPath = resolve(__dirname, '..', join('..', '..', '..', 'packages'));
|
||||
const corePath = join(rootPath, 'core', '*');
|
||||
const pluginsPath = join(rootPath, 'plugins', '*');
|
||||
const corePackageDirs = glob.sync(corePath);
|
||||
const pluginsPackageDirs = glob.sync(pluginsPath);
|
||||
|
||||
const packageDirs = [...corePackageDirs, ...pluginsPackageDirs].filter(dir => {
|
||||
const isCoreAdmin = dir.includes('packages/core/admin/');
|
||||
const isCoreAdmin = dir.includes('packages/core/admin');
|
||||
const pathToEntryPoint = join(dir, 'admin', 'src', 'index.js');
|
||||
const doesAdminFolderExist = fs.pathExistsSync(pathToEntryPoint);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user