@@ -4,6 +4,7 @@ import { type ThemeData } from '@deephaven/components';
4
4
import { dhTruck , vsPreview } from '@deephaven/icons' ;
5
5
import {
6
6
type DashboardPlugin ,
7
+ type ElementPlugin ,
7
8
type PluginModule ,
8
9
PluginType ,
9
10
type ThemePlugin ,
@@ -13,6 +14,7 @@ import {
13
14
pluginSupportsType ,
14
15
getIconForPlugin ,
15
16
getThemeDataFromPlugins ,
17
+ getPluginsElementMap ,
16
18
} from './PluginUtils' ;
17
19
18
20
function TestWidget ( ) {
@@ -32,6 +34,23 @@ const dashboardPlugin: DashboardPlugin = {
32
34
component : TestWidget ,
33
35
} ;
34
36
37
+ const ElementPluginOne : ElementPlugin = {
38
+ name : 'test-element-plugin-one' ,
39
+ type : PluginType . ELEMENT_PLUGIN ,
40
+ mapping : {
41
+ 'test-element-one' : TestWidget ,
42
+ 'test-element-two' : TestWidget ,
43
+ } ,
44
+ } ;
45
+
46
+ const ElementPluginTwo : ElementPlugin = {
47
+ name : 'test-element-plugin-two' ,
48
+ type : PluginType . ELEMENT_PLUGIN ,
49
+ mapping : {
50
+ 'test-element-three' : TestWidget ,
51
+ } ,
52
+ } ;
53
+
35
54
test ( 'pluginSupportsType' , ( ) => {
36
55
expect ( pluginSupportsType ( widgetPlugin , 'test-widget' ) ) . toBe ( true ) ;
37
56
expect ( pluginSupportsType ( widgetPlugin , 'test-widget-two' ) ) . toBe ( true ) ;
@@ -170,3 +189,32 @@ describe('getThemeDataFromPlugins', () => {
170
189
expect ( actual ) . toEqual ( expected ) ;
171
190
} ) ;
172
191
} ) ;
192
+
193
+ describe ( 'getElementPluginMap' , ( ) => {
194
+ it ( 'should return a mapping of element plugins' , ( ) => {
195
+ const pluginMap = new Map < string , PluginModule > ( [
196
+ [ ElementPluginOne . name , ElementPluginOne ] ,
197
+ [ ElementPluginTwo . name , ElementPluginTwo ] ,
198
+ [ dashboardPlugin . name , dashboardPlugin ] ,
199
+ [ widgetPlugin . name , widgetPlugin ] ,
200
+ ] ) ;
201
+
202
+ const elementMapping = getPluginsElementMap ( pluginMap ) ;
203
+
204
+ expect ( elementMapping . size ) . toBe ( 3 ) ;
205
+ expect ( elementMapping . get ( 'test-element-one' ) ) . toBe ( TestWidget ) ;
206
+ expect ( elementMapping . get ( 'test-element-two' ) ) . toBe ( TestWidget ) ;
207
+ expect ( elementMapping . get ( 'test-element-three' ) ) . toBe ( TestWidget ) ;
208
+ } ) ;
209
+
210
+ it ( 'should return an empty map if no element plugins are present' , ( ) => {
211
+ const pluginMap = new Map < string , PluginModule > ( [
212
+ [ widgetPlugin . name , widgetPlugin ] ,
213
+ [ dashboardPlugin . name , dashboardPlugin ] ,
214
+ ] ) ;
215
+
216
+ const elementMapping = getPluginsElementMap ( pluginMap ) ;
217
+
218
+ expect ( elementMapping . size ) . toBe ( 0 ) ;
219
+ } ) ;
220
+ } ) ;
0 commit comments