add some test for invalid ids
Signed-off-by: Juan Pablo Garcia Ripa <sarabadu@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { createServiceRef } from '../services';
|
||||
import { ID_PATTERN } from './constants';
|
||||
import { createBackendModule } from './createBackendModule';
|
||||
import { createExtensionPoint } from './createExtensionPoint';
|
||||
import { InternalBackendRegistrations } from './types';
|
||||
@@ -77,4 +78,20 @@ describe('createBackendModule', () => {
|
||||
|
||||
expect(plugin.$$type).toEqual('@backstage/BackendFeature');
|
||||
});
|
||||
it('should reject modules with invalid moduleId', async () => {
|
||||
expect(() =>
|
||||
createBackendModule({
|
||||
pluginId: 'test',
|
||||
moduleId: 'invalid:module&id',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: {},
|
||||
async init() {},
|
||||
});
|
||||
},
|
||||
}),
|
||||
).toThrow(
|
||||
`Invalid moduleId 'invalid:module&id' for plugin 'test', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import { createServiceRef } from '../services';
|
||||
import { ID_PATTERN } from './constants';
|
||||
import { createBackendPlugin } from './createBackendPlugin';
|
||||
import { createExtensionPoint } from './createExtensionPoint';
|
||||
import { InternalBackendRegistrations } from './types';
|
||||
@@ -90,4 +91,19 @@ describe('createBackendPlugin', () => {
|
||||
|
||||
expect(plugin.$$type).toEqual('@backstage/BackendFeature');
|
||||
});
|
||||
it('should reject plugins with invalid pluginId', async () => {
|
||||
expect(() =>
|
||||
createBackendPlugin({
|
||||
pluginId: 'test:invalid&id',
|
||||
register(reg) {
|
||||
reg.registerInit({
|
||||
deps: {},
|
||||
async init() {},
|
||||
});
|
||||
},
|
||||
}),
|
||||
).toThrow(
|
||||
`Invalid pluginId 'test:invalid&id', must match the pattern ${ID_PATTERN} (letters, digits, and dashes only, starting with a letter)`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user