-
Notifications
You must be signed in to change notification settings - Fork 24
fix: corrected stubbing errors in tests @W-21178947@ #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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([]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
| }) | ||
|
|
||
|
|
@@ -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) | ||
|
|
@@ -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) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dependency on
mocha@^10causes tests to fail on node v25, because one of the libraries usesrequireinstead ofimportand that's somehow a problem. Bumping to v11 resolves this.