mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
This commit is contained in:
parent
c119821c19
commit
cd1f95c5ea
@ -18,14 +18,14 @@ const onPluginSettingsChange = jest.fn();
|
||||
const itemEvent = ({
|
||||
item: { manifest: { id: pluginId } },
|
||||
} as ItemEvent);
|
||||
const callHook = (isUpdate: boolean, pluginEnabled = true) => () => useOnInstallHandler(
|
||||
const callHook = (isUpdate: boolean, pluginEnabled = true, pluginInstalledViaGUI = true) => () => useOnInstallHandler(
|
||||
setInstallingPluginIds,
|
||||
{
|
||||
[pluginId]: {
|
||||
[pluginId]: pluginInstalledViaGUI ? {
|
||||
enabled: pluginEnabled,
|
||||
deleted: false,
|
||||
hasBeenUpdated: false,
|
||||
},
|
||||
} : undefined,
|
||||
},
|
||||
repoApi,
|
||||
onPluginSettingsChange,
|
||||
@ -83,4 +83,9 @@ describe('useOnInstallHandler', () => {
|
||||
const newSettings = onPluginSettingsChange.mock.calls[0][0].value;
|
||||
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) => {
|
||||
draft[pluginId] = defaultPluginSetting();
|
||||
if (isUpdate) {
|
||||
draft[pluginId].enabled = pluginSettings[pluginId].enabled;
|
||||
if (pluginSettings[pluginId]) {
|
||||
draft[pluginId].enabled = pluginSettings[pluginId].enabled;
|
||||
}
|
||||
draft[pluginId].hasBeenUpdated = true;
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user