File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { describe , expect , it , vi } from 'vitest'
2+
3+ import { PluginLoader } from '../loader'
4+
5+ describe ( 'Plugin Registry' , ( ) => {
6+ it ( 'check that plugins do not override each other' , async ( ) => {
7+ const loader = new PluginLoader ( )
8+
9+ const registered = new Set < string > ( )
10+ const duplicate : string [ ] = [ ]
11+
12+ const pluginsMap = loader [ 'plugins' ] as Map < string , unknown >
13+
14+ const originalSet = pluginsMap . set . bind ( pluginsMap )
15+
16+ const setSpy = vi . spyOn ( pluginsMap , 'set' ) . mockImplementation ( ( key , value ) => {
17+ if ( registered . has ( key ) ) {
18+ duplicate . push ( key )
19+ }
20+ registered . add ( key )
21+ return originalSet ( key , value )
22+ } )
23+
24+ try {
25+ await loader . loadPlugins ( true )
26+
27+ expect ( duplicate ) . toEqual ( [ ] )
28+ } finally {
29+ setSpy . mockRestore ( )
30+ }
31+ } )
32+ } )
You can’t perform that action at this time.
0 commit comments