30 行
902 B
TypeScript
30 行
902 B
TypeScript
|
|
import assert from 'node:assert/strict'
|
||
|
|
import test from 'node:test'
|
||
|
|
|
||
|
|
import {
|
||
|
|
definePlugin,
|
||
|
|
getDefinedPluginIds,
|
||
|
|
getPluginDefinition,
|
||
|
|
removePluginDefinition,
|
||
|
|
} from '../src/PluginRegistry'
|
||
|
|
|
||
|
|
test('plugin definition is visible through the process-wide registry', () => {
|
||
|
|
const definition = { moduleId: 'registry-test', activate() {} }
|
||
|
|
definePlugin(definition)
|
||
|
|
|
||
|
|
assert.equal(getPluginDefinition('registry-test'), definition)
|
||
|
|
assert.ok(getDefinedPluginIds().includes('registry-test'))
|
||
|
|
|
||
|
|
removePluginDefinition('registry-test')
|
||
|
|
assert.equal(getPluginDefinition('registry-test'), undefined)
|
||
|
|
})
|
||
|
|
|
||
|
|
test('rejects two different definitions for the same module', () => {
|
||
|
|
definePlugin({ moduleId: 'duplicate-test', activate() {} })
|
||
|
|
assert.throws(
|
||
|
|
() => definePlugin({ moduleId: 'duplicate-test', activate() {} }),
|
||
|
|
/already defined/,
|
||
|
|
)
|
||
|
|
removePluginDefinition('duplicate-test')
|
||
|
|
})
|