Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-config-prettier": "^10",
"husky": "^9.1.7",
"lint-staged": "^15.5.2",
"mocha": "^10.8.2",
"mocha": "^11",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency on mocha@^10 causes tests to fail on node v25, because one of the libraries uses require instead of import and that's somehow a problem. Bumping to v11 resolves this.

"oclif": "^4.22.79",
"prettier": "^3.8.1",
"shx": "^0.4.0",
Expand Down
46 changes: 28 additions & 18 deletions test/commands/plugins/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,65 +8,75 @@ describe('plugins', () => {
sinon.restore()
})

it('shows no plugins installed', async () => {
it('when no plugins installed, says so', async () => {
const config = await Config.load(import.meta.url)
sinon.stub(config, 'getPluginsList').returns([])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stubbing an empty array didn't seem to actually do anything functionally, and was just causing the tests to explode, so I just got rid of it. All of the other tests include the existing plugin list anyway, so it follows that this one should do so as well.


const {stdout} = await runCommand('plugins', config, {print: true})
const {error, stdout} = await runCommand('plugins', config, {print: true})
expect(error).to.be.undefined
expect(stdout).to.equal('No plugins installed.\n')
})

it('lists user plugins in stdout', async () => {
it('lists installed user plugins in stdout', async () => {
const config = await Config.load(import.meta.url)
config.options
const plugins = [
...config.getPluginsList(),
{name: 'user-plugin-1', type: 'user', version: '1.0.0'},
{name: 'user-plugin-2', type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'user-plugin-1', topics: [], type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'user-plugin-2', topics: [], type: 'user', version: '1.0.0'},
]
// @ts-expect-error because we aren't stubbing the entire Plugin instance
sinon.stub(config, 'getPluginsList').returns(plugins)

const {stdout} = await runCommand('plugins', config)
const {error, stdout} = await runCommand('plugins', config)
expect(error).to.be.undefined
expect(stdout).to.equal('user-plugin-1 1.0.0\nuser-plugin-2 1.0.0\n')
})

it('lists nested user plugins in stdout', async () => {
it('lists installed nested user plugins in stdout', async () => {
const config = await Config.load(import.meta.url)
const plugins = [
...config.getPluginsList(),
{
children: [
{
commands: [],
hooks: new Map(),
name: 'user-plugin-2',
topics: [],
type: 'user',
version: '1.0.0',
},
],
commands: [],
hooks: new Map(),
name: 'user-plugin-1',
topics: [],
type: 'user',
version: '1.0.0',
},
]
// @ts-expect-error because we aren't stubbing the entire Plugin instance
sinon.stub(config, 'getPluginsList').returns(plugins)

const {stdout} = await runCommand('plugins', config)
const {error, stdout} = await runCommand('plugins', config)
expect(error).to.be.undefined
expect(stdout).to.equal(`user-plugin-1 1.0.0
└─ user-plugin-2 1.0.0
`)
})

it('lists dev plugins in stdout with --core', async () => {
it('lists installed dev plugins in stdout with --core', async () => {
const config = await Config.load(import.meta.url)
const plugins = [
...config.getPluginsList(),
{name: 'dev-plugin-1', type: 'dev', version: '1.0.0'},
{name: 'user-plugin-1', type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'dev-plugin-1', topics: [], type: 'dev', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'user-plugin-1', topics: [], type: 'user', version: '1.0.0'},
]
// @ts-expect-error because we aren't stubbing the entire Plugin instance
sinon.stub(config, 'getPluginsList').returns(plugins)

const {stdout} = await runCommand('plugins --core', config)
const {error, stdout} = await runCommand('plugins --core', config)
expect(error).to.be.undefined
expect(stdout).to.equal('dev-plugin-1 1.0.0 (dev)\nuser-plugin-1 1.0.0\n')
})

Expand All @@ -82,8 +92,8 @@ describe('plugins', () => {
})
const plugins = [
...config.getPluginsList(),
{name: 'user-plugin-1', type: 'user', version: '1.0.0'},
{name: 'jit-plugin-1', type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'user-plugin-1', topics: [], type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'jit-plugin-1', topics: [], type: 'user', version: '1.0.0'},
]
// @ts-expect-error because we aren't stubbing the entire Plugin instance
sinon.stub(config, 'getPluginsList').returns(plugins)
Expand All @@ -102,9 +112,9 @@ jit-plugin-3 1.0.0
const config = await Config.load(import.meta.url)
const plugins = [
...config.getPluginsList(),
{name: 'user-plugin-1', type: 'user', version: '1.0.0'},
{name: 'dev-plugin-1', type: 'dev', version: '1.0.0'},
{name: 'core-plugin-1', type: 'core', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'user-plugin-1', topics: [], type: 'user', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'dev-plugin-1', topics: [], type: 'dev', version: '1.0.0'},
{commands: [], hooks: new Map(), name: 'core-plugin-1', topics: [], type: 'core', version: '1.0.0'},
]
// @ts-expect-error because we aren't stubbing the entire Plugin instance
sinon.stub(config, 'getPluginsList').returns(plugins)
Expand Down
Loading