This repository was archived by the owner on Jan 16, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 11import { SyntheticEvent } from 'react' ;
22
3- import { copyToClipBoardUtility } from './cli-utils' ;
3+ import { copyToClipBoardUtility , getCLISetConfigRegistry } from './cli-utils' ;
44
55describe ( 'copyToClipBoardUtility' , ( ) => {
66 let originalGetSelection ;
@@ -47,3 +47,18 @@ describe('copyToClipBoardUtility', () => {
4747 expect ( spys . removeChild ) . toHaveBeenCalledWith ( expectedDiv ) ;
4848 } ) ;
4949} ) ;
50+
51+ describe ( 'getCLISetRegistry' , ( ) => {
52+ const command = 'npm set' ;
53+ const scope = '@testscope' ;
54+ const blankScope = '' ;
55+ const url = 'https://test.local' ;
56+
57+ test ( 'should return ":" separated string when scope is set' , ( ) => {
58+ expect ( getCLISetConfigRegistry ( command , scope , url ) ) . toEqual ( `${ command } ${ scope } :registry ${ url } ` ) ;
59+ } ) ;
60+
61+ test ( 'should not output scope when scope is not set' , ( ) => {
62+ expect ( getCLISetConfigRegistry ( command , blankScope , url ) ) . toEqual ( `${ command } registry ${ url } ` ) ;
63+ } ) ;
64+ } ) ;
Original file line number Diff line number Diff line change @@ -21,7 +21,8 @@ export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLEle
2121} ;
2222
2323export function getCLISetConfigRegistry ( command : string , scope : string , registryUrl : string ) : string {
24- return `${ command } ${ scope } registry ${ registryUrl } ` ;
24+ // if there is a scope defined there needs to be a ":" separator between the scope and the registry
25+ return `${ command } ${ scope } ${ scope !== '' ? ':' : '' } registry ${ registryUrl } ` ;
2526}
2627
2728export function getCLISetRegistry ( command : string , registryUrl : string ) : string {
You can’t perform that action at this time.
0 commit comments