Skip to content

Commit

Permalink
Enable dynamic slicing the component names retrieved from componentCr…
Browse files Browse the repository at this point in the history
…eators
  • Loading branch information
shammowla committed Jan 17, 2024
1 parent f0ad91f commit 683493d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scripts/helpers/customBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ const componentNames = componentCreatorsContent.match(/create[A-Z]\w+/g);

// Format component names for export
const formattedComponentNames = componentNames.map(name => ({
name: name.slice(6).toLowerCase(),
name: name.replace(/^create/, "").toLowerCase(),
exportName: name,
filePath: name.slice(6)
filePath: name.replace(/^create/, "")
}));

// Extract required components from componentCreatorsContent
const requiredComponents = componentCreatorsContent
.match(/REQUIRED_COMPONENTS = \[[\s\S]*?\]/)[0]
.match(/create[A-Z]\w+/g)
.map(component => component.slice(6).toLowerCase());
.map(component => component.replace(/^create/, "").toLowerCase());

const argv = yargs(hideBin(process.argv))
.scriptName("build:custom")
Expand Down
14 changes: 11 additions & 3 deletions test/unit/specs/core/componentCreators.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ governing permissions and limitations under the License.
import componentCreators from "../../../../src/core/componentCreators";

describe("componentCreators", () => {
it("is an array of component creators", () => {
expect(componentCreators).toEqual(jasmine.any(Array));
componentCreators.forEach(componentCreator => {
it("is an object with arrays of component creators", () => {
expect(componentCreators).toEqual(jasmine.any(Object));
expect(componentCreators.REQUIRED_COMPONENTS).toEqual(jasmine.any(Array));
expect(componentCreators.OPTIONAL_COMPONENTS).toEqual(jasmine.any(Array));

const allComponentCreators = [
...componentCreators.REQUIRED_COMPONENTS,
...componentCreators.OPTIONAL_COMPONENTS
];

allComponentCreators.forEach(componentCreator => {
expect(componentCreator).toEqual(jasmine.any(Function));
expect(componentCreator.namespace).toEqual(jasmine.any(String));

Expand Down

0 comments on commit 683493d

Please sign in to comment.