1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/lib/services/plugins/utils/validatePluginId.test.ts
2021-01-07 19:30:29 +00:00

33 lines
830 B
TypeScript

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