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:
@ -84,7 +84,7 @@ describe('models/Setting', () => {
|
||||
expect(Setting.value('myCustom')).toBe('123');
|
||||
}));
|
||||
|
||||
it('should not clear old custom settings', (async () => {
|
||||
it.each([SettingStorage.Database, SettingStorage.File])('should not clear old custom settings if not registered immediately', (async (storage) => {
|
||||
// In general the following should work:
|
||||
//
|
||||
// - Plugin register a new setting
|
||||
@ -105,6 +105,7 @@ describe('models/Setting', () => {
|
||||
public: true,
|
||||
value: 'default',
|
||||
type: Setting.TYPE_STRING,
|
||||
storage,
|
||||
});
|
||||
|
||||
Setting.setValue('myCustom', '123');
|
||||
@ -119,6 +120,7 @@ describe('models/Setting', () => {
|
||||
public: true,
|
||||
value: 'default',
|
||||
type: Setting.TYPE_STRING,
|
||||
storage,
|
||||
});
|
||||
|
||||
await Setting.saveAll();
|
||||
@ -126,6 +128,34 @@ describe('models/Setting', () => {
|
||||
expect(Setting.value('myCustom')).toBe('123');
|
||||
}));
|
||||
|
||||
it.each([SettingStorage.Database, SettingStorage.File])('should not clear old custom settings if not registered until restart', async (storage) => {
|
||||
const registerCustom = async () => {
|
||||
await Setting.registerSetting('myCustom', {
|
||||
public: true,
|
||||
value: 'test',
|
||||
type: Setting.TYPE_STRING,
|
||||
storage,
|
||||
});
|
||||
};
|
||||
|
||||
await registerCustom();
|
||||
Setting.setValue('myCustom', 'test2');
|
||||
await Setting.saveAll();
|
||||
|
||||
await Setting.reset();
|
||||
await Setting.load();
|
||||
|
||||
// Change a file setting
|
||||
Setting.setValue('sync.target', 9);
|
||||
|
||||
await Setting.saveAll();
|
||||
await Setting.reset();
|
||||
await Setting.load();
|
||||
|
||||
await registerCustom();
|
||||
expect(Setting.value('myCustom')).toBe('test2');
|
||||
});
|
||||
|
||||
it('should return values with correct type for custom settings', (async () => {
|
||||
await Setting.registerSetting('myCustom', {
|
||||
public: true,
|
||||
@ -425,5 +455,4 @@ describe('models/Setting', () => {
|
||||
await Setting.saveAll();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user