fix tests

This commit is contained in:
Sebastian 2022-06-24 12:32:37 -03:00
parent 50379a1d5b
commit c239967813
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1

View File

@ -24,8 +24,8 @@ import * as pages from "./pages/home/index.storiesNo.js";
setupI18n("en", { en: {} }); setupI18n("en", { en: {} });
function testThisStory(st: any): any { function testThisStory(key: string, st: any): any {
describe(`render examples for ${(st as any).default.title}`, () => { describe(`render examples for ${key}`, () => {
Object.keys(st).forEach((k) => { Object.keys(st).forEach((k) => {
const Component = (st as any)[k]; const Component = (st as any)[k];
if (k === "default" || !Component) return; if (k === "default" || !Component) return;
@ -38,11 +38,12 @@ function testThisStory(st: any): any {
} }
describe("render every storybook example", () => { describe("render every storybook example", () => {
[pages].forEach(function testAll(st: any) { Object.entries(pages).forEach(function testAll([key, value]) {
const st: any = value;
if (Array.isArray(st.default)) { if (Array.isArray(st.default)) {
st.default.forEach(testAll); st.default.forEach(testAll);
} else { } else {
testThisStory(st); testThisStory(key, st);
} }
}); });
}); });