You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Tools: Various improvements on plugin-repo-cli
This commit is contained in:
93
packages/plugin-repo-cli/lib/checkIfPluginCanBeAdded.test.ts
Normal file
93
packages/plugin-repo-cli/lib/checkIfPluginCanBeAdded.test.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import checkIfPluginCanBeAdded from './checkIfPluginCanBeAdded';
|
||||
|
||||
describe('checkIfPluginCanBeAdded', () => {
|
||||
|
||||
test('should not add if already a plugin with this ID but different package name', () => {
|
||||
const testCases = [
|
||||
[
|
||||
{
|
||||
'test': {
|
||||
id: 'test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
true,
|
||||
],
|
||||
[
|
||||
{
|
||||
'test': {
|
||||
id: 'test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'test',
|
||||
_npm_package_name: 'cantdothat',
|
||||
},
|
||||
false,
|
||||
],
|
||||
];
|
||||
|
||||
for (const t of testCases) {
|
||||
const [existingManifests, manifest, shouldWork] = t;
|
||||
|
||||
let hasThrown = false;
|
||||
try {
|
||||
checkIfPluginCanBeAdded(existingManifests, manifest);
|
||||
} catch (error) {
|
||||
hasThrown = true;
|
||||
}
|
||||
|
||||
expect(!hasThrown).toBe(shouldWork);
|
||||
}
|
||||
});
|
||||
|
||||
test('should not add if already a plugin with this ID but a different case', () => {
|
||||
const testCases = [
|
||||
[
|
||||
{
|
||||
'test': {
|
||||
id: 'test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'newone',
|
||||
_npm_package_name: 'otherpackage',
|
||||
},
|
||||
true,
|
||||
],
|
||||
[
|
||||
{
|
||||
'test': {
|
||||
id: 'test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'Test',
|
||||
_npm_package_name: 'original',
|
||||
},
|
||||
false,
|
||||
],
|
||||
];
|
||||
|
||||
for (const t of testCases) {
|
||||
const [existingManifests, manifest, shouldWork] = t;
|
||||
|
||||
let hasThrown = false;
|
||||
try {
|
||||
checkIfPluginCanBeAdded(existingManifests, manifest);
|
||||
} catch (error) {
|
||||
hasThrown = true;
|
||||
}
|
||||
|
||||
expect(!hasThrown).toBe(shouldWork);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user