V2Wizard/Test: Add docstring to preparePathname helper

preparePathname() is called by the render() test helper function, this
commit adds a docstring (JSDoc format) with examples to document how it
works.
This commit is contained in:
lucasgarfield 2024-03-01 18:36:14 +01:00 committed by Lucas Garfield
parent ad5d2007bb
commit 25a5ff7772

View file

@ -55,7 +55,15 @@ export const blueprintRequest: CreateBlueprintRequest = {
customizations: {},
};
const preparePathname = (searchParams: {}) => {
/**
* @example
* // returns 'imageWizard?release=rhel8&architecture=aarch64'
* preparePathname({ release: 'rhel8', architecture: 'aarch64' });
* @example
* // returns 'imageWizard'
* preparePathname({});
*/
function preparePathname(searchParams: { [key: string]: string } = {}): string {
let pathName = 'imageWizard';
const params = Object.entries(searchParams).map(
([param, value]) => `${param}=${value}`
@ -64,7 +72,7 @@ const preparePathname = (searchParams: {}) => {
pathName += `?${params.join('&')}`;
}
return pathName;
};
}
export const render = async (searchParams = {}) => {
const pathName = preparePathname(searchParams);