mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 10:00:17 +05:30
feat(plugins): add PluginContext, PluginRegistry, and SettingsStore
- PluginContext: scoped API with crash-safe command wrappers - PluginRegistry: lifecycle management with graceful init failure - SettingsStore: plugin-scoped key/value via IPC backend - Export hooks: pre/post hooks on registry for cross-plugin integration Amit Haridas
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
const { SettingsStore } = require('../src/plugins/settings-store');
|
||||
|
||||
describe('SettingsStore', () => {
|
||||
let store;
|
||||
let data;
|
||||
|
||||
beforeEach(() => {
|
||||
data = {};
|
||||
store = new SettingsStore({
|
||||
get: (key) => data[key],
|
||||
set: (key, value) => { data[key] = value; }
|
||||
});
|
||||
});
|
||||
|
||||
test('get returns value for full key', () => {
|
||||
data['plugins.my-plugin.myKey'] = 'myValue';
|
||||
expect(store.get('plugins.my-plugin.myKey')).toBe('myValue');
|
||||
});
|
||||
|
||||
test('get returns undefined for missing key', () => {
|
||||
expect(store.get('plugins.my-plugin.missing')).toBeUndefined();
|
||||
});
|
||||
|
||||
test('set stores value', () => {
|
||||
store.set('plugins.my-plugin.myKey', 42);
|
||||
expect(data['plugins.my-plugin.myKey']).toBe(42);
|
||||
});
|
||||
|
||||
test('set overwrites existing value', () => {
|
||||
data['plugins.my-plugin.myKey'] = 'old';
|
||||
store.set('plugins.my-plugin.myKey', 'new');
|
||||
expect(data['plugins.my-plugin.myKey']).toBe('new');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user