test(ui): assert public prop exports are detected
This commit is contained in:
parent
2535dccff2
commit
5dccd70e0b
1 changed files with 9 additions and 1 deletions
|
|
@ -138,14 +138,20 @@ describe("Storybook inventory", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("exports component prop interfaces through grouped package entrypoints", () => {
|
test("exports component prop interfaces through grouped package entrypoints", () => {
|
||||||
|
let propInterfaceCount = 0;
|
||||||
|
|
||||||
for (const component of componentInventory()) {
|
for (const component of componentInventory()) {
|
||||||
const source = readFileSync(component.path, "utf8");
|
const source = readFileSync(component.path, "utf8");
|
||||||
const propTypeName = `${component.name}Props`;
|
const propTypeName = `${component.name}Props`;
|
||||||
|
const propExportPattern = new RegExp(
|
||||||
|
`export\\s+(interface|type)\\s+${propTypeName}\\b`,
|
||||||
|
);
|
||||||
|
|
||||||
if (!source.match(new RegExp(`export\\\\s+(interface|type)\\\\s+${propTypeName}\\\\b`))) {
|
if (!propExportPattern.test(source)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
propInterfaceCount += 1;
|
||||||
const domainIndexSource = readFileSync(
|
const domainIndexSource = readFileSync(
|
||||||
join(componentsDir, component.domain, "index.ts"),
|
join(componentsDir, component.domain, "index.ts"),
|
||||||
"utf8",
|
"utf8",
|
||||||
|
|
@ -155,6 +161,8 @@ describe("Storybook inventory", () => {
|
||||||
`export * from "./${component.name}";`,
|
`export * from "./${component.name}";`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expect(propInterfaceCount).toBeGreaterThan(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("keeps Storybook fixtures generic and content-free", () => {
|
test("keeps Storybook fixtures generic and content-free", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue