You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
This commit is contained in:
@ -18,14 +18,14 @@ const onPluginSettingsChange = jest.fn();
|
|||||||
const itemEvent = ({
|
const itemEvent = ({
|
||||||
item: { manifest: { id: pluginId } },
|
item: { manifest: { id: pluginId } },
|
||||||
} as ItemEvent);
|
} as ItemEvent);
|
||||||
const callHook = (isUpdate: boolean, pluginEnabled = true) => () => useOnInstallHandler(
|
const callHook = (isUpdate: boolean, pluginEnabled = true, pluginInstalledViaGUI = true) => () => useOnInstallHandler(
|
||||||
setInstallingPluginIds,
|
setInstallingPluginIds,
|
||||||
{
|
{
|
||||||
[pluginId]: {
|
[pluginId]: pluginInstalledViaGUI ? {
|
||||||
enabled: pluginEnabled,
|
enabled: pluginEnabled,
|
||||||
deleted: false,
|
deleted: false,
|
||||||
hasBeenUpdated: false,
|
hasBeenUpdated: false,
|
||||||
},
|
} : undefined,
|
||||||
},
|
},
|
||||||
repoApi,
|
repoApi,
|
||||||
onPluginSettingsChange,
|
onPluginSettingsChange,
|
||||||
@ -83,4 +83,9 @@ describe('useOnInstallHandler', () => {
|
|||||||
const newSettings = onPluginSettingsChange.mock.calls[0][0].value;
|
const newSettings = onPluginSettingsChange.mock.calls[0][0].value;
|
||||||
expect(newSettings[pluginId].hasBeenUpdated).toBe(true);
|
expect(newSettings[pluginId].hasBeenUpdated).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not fail when plugin was not installed through the GUI', async () => {
|
||||||
|
const { result: { current: onUpdate } } = renderHook(callHook(true, true, false));
|
||||||
|
await onUpdate(itemEvent);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -40,7 +40,9 @@ export default function(setInstallingPluginIds: Function, pluginSettings: Plugin
|
|||||||
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
const newSettings = produce(pluginSettings, (draft: PluginSettings) => {
|
||||||
draft[pluginId] = defaultPluginSetting();
|
draft[pluginId] = defaultPluginSetting();
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
draft[pluginId].enabled = pluginSettings[pluginId].enabled;
|
if (pluginSettings[pluginId]) {
|
||||||
|
draft[pluginId].enabled = pluginSettings[pluginId].enabled;
|
||||||
|
}
|
||||||
draft[pluginId].hasBeenUpdated = true;
|
draft[pluginId].hasBeenUpdated = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user