1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/lib/services/plugins/utils/validatePluginId.test.ts

35 lines
1.0 KiB
TypeScript
Raw Normal View History

import validatePluginId from './validatePluginId';
describe('validatePluginId', () => {
test('should validate an ID', () => {
const okCases = [
'joplinapp.org.plugins.thatsok',
'joplinapp.org.plugins.that-s-ok',
'joplinapp.org.plugins.that_s_fine12',
'joplinapp.org.plugins.com.ok.too',
'joplinapp.org.plugins.Good',
'outline',
];
const errorCases = [
'',
'verylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongidverylongid',
'-shouldstartwiththis',
'shouldntendwithit.',
' no space no space no space no space ',
'no spaceno spaceno spaceno spaceno space',
'tooshort',
];
for (const t of okCases) {
expect(() => validatePluginId(t)).not.toThrow();
}
for (const t of errorCases) {
expect(() => validatePluginId(t)).toThrow();
}
});
});