@bangle.dev/core
Advanced tools
Comparing version 0.16.1 to 0.16.2
{ | ||
"name": "@bangle.dev/core", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"homepage": "https://bangle.dev", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -86,2 +86,50 @@ import { SpecRegistry } from '../../spec-registry'; | ||
test('passes params correctly to plugins which are functions', () => { | ||
const pluginFn = jest.fn( | ||
() => new Plugin({ key: new PluginKey('myPlug') }), | ||
); | ||
const groupChildPluginFn = jest.fn( | ||
() => new Plugin({ key: new PluginKey('grp1.first') }), | ||
); | ||
const group1 = new PluginGroup('grp1', [[groupChildPluginFn]]); | ||
expect( | ||
pluginLoader(specRegistry, [group1, pluginFn]) | ||
.map((r) => r.key) | ||
.includes('myPlug$'), | ||
).toBe(true); | ||
expect(pluginFn).toBeCalledTimes(1); | ||
expect(groupChildPluginFn).toBeCalledTimes(1); | ||
expect(pluginFn).nthCalledWith(1, { | ||
specRegistry, | ||
schema: specRegistry.schema, | ||
metadata: {}, | ||
}); | ||
expect(groupChildPluginFn).nthCalledWith(1, { | ||
specRegistry, | ||
schema: specRegistry.schema, | ||
metadata: {}, | ||
}); | ||
}); | ||
test('passes params metadata correctly to plugins which are functions', () => { | ||
const pluginFn = jest.fn(() => new Plugin({ key: new PluginKey('myPug') })); | ||
const metadata = { hello: 'world' }; | ||
expect( | ||
pluginLoader(specRegistry, [pluginFn], { metadata }) | ||
.map((r) => r.key) | ||
.includes('myPug$'), | ||
).toBe(true); | ||
expect(pluginFn).toBeCalledTimes(1); | ||
expect(pluginFn).nthCalledWith(1, { | ||
specRegistry, | ||
schema: specRegistry.schema, | ||
metadata, | ||
}); | ||
}); | ||
test('Throws error if duplicate groups', () => { | ||
@@ -88,0 +136,0 @@ const group1_child = new PluginGroup('grp1_child', [ |
@@ -28,8 +28,10 @@ import { | ||
const schema = specRegistry.schema; | ||
let [flatPlugins, pluginGroupNames] = flatten(plugins, { | ||
const pluginPayload = { | ||
schema, | ||
specRegistry, | ||
}); | ||
metadata, | ||
}; | ||
let [flatPlugins, pluginGroupNames] = flatten(plugins, pluginPayload); | ||
if (defaultPlugins) { | ||
@@ -47,3 +49,3 @@ let defaultPluginGroups = []; | ||
flatPlugins = flatPlugins.concat( | ||
flatten(defaultPluginGroups, { schema, specRegistry, metadata })[0], | ||
flatten(defaultPluginGroups, pluginPayload)[0], | ||
); | ||
@@ -50,0 +52,0 @@ |
532020
19351