Skip to content

Commit e6aa582

Browse files
committed
duplicate registry IDs test
1 parent d431dee commit e6aa582

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
})

0 commit comments

Comments
 (0)