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

35 lines
1.0 KiB
TypeScript

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();
}
});
});