1
0
mirror of https://github.com/SomboChea/ui synced 2024-11-28 00:44:30 +07:00

fix: when scope is provided use proper separator (#457)

This commit is contained in:
Gjorgji Jankovski 2020-05-05 09:17:33 +02:00 committed by GitHub
parent b59840d352
commit 7e56c8e7e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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}`);
});
});

View File

@ -21,7 +21,8 @@ export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLEle
};
export function getCLISetConfigRegistry(command: string, scope: string, registryUrl: string): string {
return `${command} ${scope}registry ${registryUrl}`;
// if there is a scope defined there needs to be a ":" separator between the scope and the registry
return `${command} ${scope}${scope !== '' ? ':' : ''}registry ${registryUrl}`;
}
export function getCLISetRegistry(command: string, registryUrl: string): string {