@@ -14,7 +14,7 @@ import { shouldThrow } from '@salesforce/core/lib/testSetup';
1414import { marked } from 'marked' ;
1515import { Env } from '@salesforce/kit' ;
1616import { Lifecycle } from '@salesforce/core' ;
17- import { Config } from '@oclif/core' ;
17+ import { Config , Plugin } from '@oclif/core' ;
1818import { SfCommand } from '@salesforce/sf-plugins-core' ;
1919import * as getInfoConfig from '../../../../src/shared/getInfoConfig' ;
2020import * as getReleaseNotes from '../../../../src/shared/getReleaseNotes' ;
@@ -39,6 +39,7 @@ describe('info:releasenotes:display', () => {
3939 let markedParserSpy : Sinon . SinonSpy ;
4040
4141 const oclifConfigStub = fromStub ( stubInterface < Config > ( sandbox ) ) ;
42+ const oclifPluginStub = fromStub ( stubInterface < Plugin > ( sandbox ) ) ;
4243
4344 class TestDisplay extends Display {
4445 public async runIt ( ) {
@@ -48,7 +49,8 @@ describe('info:releasenotes:display', () => {
4849 }
4950
5051 const runDisplayCmd = async ( params : string [ ] ) => {
51- oclifConfigStub . bin = 'sfdx' ;
52+ oclifConfigStub . name = 'sfdx-cli' ;
53+ oclifPluginStub . name = 'sfdx-plugin' ;
5254
5355 const cmd = new TestDisplay ( params , oclifConfigStub ) ;
5456
@@ -70,6 +72,9 @@ describe('info:releasenotes:display', () => {
7072 oclifConfigStub . pjson . version = '3.3.3' ;
7173 oclifConfigStub . root = '/root/path' ;
7274
75+ oclifPluginStub . pjson . version = '3.3.3' ;
76+ oclifConfigStub . plugins = [ oclifPluginStub ] ;
77+
7378 getBooleanStub = stubMethod ( sandbox , Env . prototype , 'getBoolean' ) ;
7479 getBooleanStub . withArgs ( 'SFDX_HIDE_RELEASE_NOTES' ) . returns ( false ) ;
7580 getBooleanStub . withArgs ( 'SFDX_HIDE_RELEASE_NOTES_FOOTER' ) . returns ( false ) ;
@@ -168,7 +173,21 @@ describe('info:releasenotes:display', () => {
168173 it ( 'logs logs a header with cli bin' , async ( ) => {
169174 await runDisplayCmd ( [ ] ) ;
170175
171- expect ( uxLogStub . args [ 0 ] [ 0 ] ) . to . contain ( "# Release notes for 'sfdx':" ) ;
176+ expect ( uxLogStub . args [ 0 ] [ 0 ] ) . to . contain ( "# Release notes for 'sfdx-cli':" ) ;
177+ } ) ;
178+
179+ it ( 'logs logs a header with plugin' , async ( ) => {
180+ await runDisplayCmd ( [ 'sfdx-plugin' ] ) ;
181+
182+ expect ( uxLogStub . args [ 0 ] [ 0 ] ) . to . contain ( "# Release notes for 'sfdx-plugin':" ) ;
183+ } ) ;
184+
185+ it ( 'throws an error if plugin name is invalid' , async ( ) => {
186+ try {
187+ await shouldThrow ( runDisplayCmd ( [ 'no-plugin' ] ) ) ;
188+ } catch ( err ) {
189+ expect ( ( err as Error ) . message ) . to . contain ( "No plugin 'no-plugin' found" ) ;
190+ }
172191 } ) ;
173192
174193 it ( 'calls getReleaseNotes with passed version' , async ( ) => {
@@ -257,7 +276,7 @@ describe('info:releasenotes:display', () => {
257276 const json = await runDisplayCmd ( [ '--json' ] ) ;
258277
259278 const expected = {
260- body : `# Release notes for 'sfdx':${ os . EOL } ## Release notes for 3.3.3` ,
279+ body : `# Release notes for 'sfdx-cli ':${ os . EOL } ## Release notes for 3.3.3` ,
261280 url : mockInfoConfig . releasenotes . releaseNotesPath ,
262281 } ;
263282
0 commit comments