Skip to content

Commit

Permalink
chore: Removes the getComponentsMetadata public API
Browse files Browse the repository at this point in the history
  • Loading branch information
orangevolon committed Jan 15, 2025
1 parent a2725f4 commit f99a944
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 112 deletions.
12 changes: 0 additions & 12 deletions src/converter/generate-component-finders.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { ComponentWrapperMetadata, TestUtilType } from './interfaces';
import { buildComponentsMetadataMap } from './utils';

const componentWrapperImport = ({ wrapperName, wrapperImportPath }: ComponentWrapperMetadata) => `
import ${wrapperName} from '${wrapperImportPath}';`;
Expand Down Expand Up @@ -102,16 +101,5 @@ declare module '@cloudscape-design/test-utils-core/dist/${testUtilType}' {
${components.map(componentFinders).join('')}
/**
* Returns the component metadata including its plural and wrapper name.
*
* @param {string} componentName Component name in pascal case.
* @returns {ComponentMetadata}
*/
export function getComponentMetadata(componentName: string) {
return ${buildComponentsMetadataMap(components)}[componentName];
}
${defaultExport[testUtilType]}
`;
14 changes: 0 additions & 14 deletions src/converter/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,3 @@ export interface ComponentWrapperMetadata extends ComponentMetadata {
*/
wrapperImportPath: string;
}

export interface ComponentPublicMetadata {
/**
* Plural name of the component in pascal case.
* Examples: Buttons, Alerts, ButtonDropdowns
*/
pluralName: string;

/*
* Name of the component wrapper in pascal case
* Examples: ButtonWrapper, AlertWrapper, ButtonDropdownWrapper
*/
wrapperName: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,6 @@ ElementWrapper.prototype.findAllTestComponentBs = function(selector) {
};
/**
* Returns the component metadata including its plural and wrapper name.
*
* @param {string} componentName Component name in pascal case.
* @returns {ComponentMetadata}
*/
export function getComponentMetadata(componentName: string) {
return {"TestComponentA":{"pluralName":"TestComponentAs","wrapperName":"TestComponentAWrapper"},"TestComponentB":{"pluralName":"TestComponentBs","wrapperName":"TestComponentBWrapper"}}[componentName];
}
export default function wrapper(root: Element = document.body) {
if (document && document.body && !document.body.contains(root)) {
console.warn('[AwsUi] [test-utils] provided element is not part of the document body, interactions may work incorrectly')
Expand Down Expand Up @@ -182,17 +171,6 @@ ElementWrapper.prototype.findAllTestComponentBs = function(selector) {
};
/**
* Returns the component metadata including its plural and wrapper name.
*
* @param {string} componentName Component name in pascal case.
* @returns {ComponentMetadata}
*/
export function getComponentMetadata(componentName: string) {
return {"TestComponentA":{"pluralName":"TestComponentAs","wrapperName":"TestComponentAWrapper"},"TestComponentB":{"pluralName":"TestComponentBs","wrapperName":"TestComponentBWrapper"}}[componentName];
}
export default function wrapper(root: string = 'body') {
return new ElementWrapper(root);
}
Expand Down
4 changes: 0 additions & 4 deletions src/converter/test/generate-component-finders.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ describe(`${generateComponentFinders.name}`, () => {
expect(sourceFileContent).toMatch('ElementWrapper.prototype.findAllStatus = function(selector)');
});

test('it exports the component metadata helper', () => {
expect(sourceFileContent).toMatch(`export function getComponentMetadata(componentName: string)`);
});

test('it exports the wrapper creator', () => {
if (testUtilType === 'dom') {
expect(sourceFileContent).toMatch('export default function wrapper(root: Element = document.body)');
Expand Down
46 changes: 0 additions & 46 deletions src/converter/test/utils.test.ts

This file was deleted.

14 changes: 0 additions & 14 deletions src/converter/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
import fs from 'fs';
import path from 'path';
import { ComponentPublicMetadata, ComponentWrapperMetadata } from './interfaces';

export function buildComponentsMetadataMap(components: ComponentWrapperMetadata[]): string {
const componentPublicMetadata: Record<string, ComponentPublicMetadata> = {};

for (const { name, pluralName, wrapperName } of components) {
componentPublicMetadata[name] = {
pluralName,
wrapperName,
};
}

return JSON.stringify(componentPublicMetadata);
}

export function writeSourceFile(filepath: string, content: string) {
fs.mkdirSync(path.dirname(filepath), { recursive: true });
Expand Down

0 comments on commit f99a944

Please sign in to comment.