diff --git a/src/utils/cli-utils.test.ts b/src/utils/cli-utils.test.ts index 1fbc255..e0d071d 100644 --- a/src/utils/cli-utils.test.ts +++ b/src/utils/cli-utils.test.ts @@ -1,6 +1,6 @@ import { SyntheticEvent } from 'react'; -import { copyToClipBoardUtility } from './cli-utils'; +import { copyToClipBoardUtility, getCLISetConfigRegistry } from './cli-utils'; describe('copyToClipBoardUtility', () => { let originalGetSelection; @@ -47,3 +47,18 @@ describe('copyToClipBoardUtility', () => { expect(spys.removeChild).toHaveBeenCalledWith(expectedDiv); }); }); + +describe('getCLISetRegistry', () => { + const command = 'npm set'; + const scope = '@testscope'; + const blankScope = ''; + const url = 'https://test.local'; + + test('should return ":" separated string when scope is set', () => { + expect(getCLISetConfigRegistry(command, scope, url)).toEqual(`${command} ${scope}:registry ${url}`); + }); + + test('should not output scope when scope is not set', () => { + expect(getCLISetConfigRegistry(command, blankScope, url)).toEqual(`${command} registry ${url}`); + }); +}); diff --git a/src/utils/cli-utils.ts b/src/utils/cli-utils.ts index c695543..79d9637 100644 --- a/src/utils/cli-utils.ts +++ b/src/utils/cli-utils.ts @@ -21,7 +21,8 @@ export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent