1
0
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:
Laurent Cozic
2021-01-21 00:12:59 +00:00
parent f37d37e613
commit f9b0e2f6df
13 changed files with 539 additions and 3286 deletions

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