From 7e56c8e7e27cc2e2ab9ba509c8fbc722d9832afa Mon Sep 17 00:00:00 2001 From: Gjorgji Jankovski Date: Tue, 5 May 2020 09:17:33 +0200 Subject: [PATCH] fix: when scope is provided use proper separator (#457) --- src/utils/cli-utils.test.ts | 17 ++++++++++++++++- src/utils/cli-utils.ts | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) 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