Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function normalize(string) {
return string.replace(/[ -/]/g, '_');
}
// Remove the GeoSearch stories from the
// tests because they are too brittle
const stories = require.context(
'../../stories',
true,
/^((?!GeoSearch).)*\.stories\.js$/
);
// loadStories
stories.keys().forEach(filename => stories(filename));
const tests = getStorybook().reduce((acc, book) => {
book.stories.forEach(story => {
acc.push({
suite: normalize(book.kind),
name: normalize(story.name),
case: story.render,
context: {
kind: book.kind,
story: story.name,
},
});
});
return acc;
}, []);
let interval;
export function getStorybookInfo(): StoryGroupInfo[] {
requireAllStories();
return getStorybook()
.filter(({ kind }) => kind)
.map(({ kind: group, stories: storiesRaw }) => {
const stories: StoryInfo[] = storiesRaw
.filter(({ name }) => name)
.map(({ name: title }) => {
// cleans story name to match url params
const encodedTitle = encodeString(title);
return {
title,
encodedTitle,
};
});
const encodedGroup = encodeString(group);
it('should validate on default usage', () => {
getStorybook().forEach(({ kind, stories }) =>
stories.forEach(({ name, render }) => render())
);
});
});
it('should validate on default usage', () => {
getStorybook().forEach(({ kind, stories }) =>
stories.forEach(({ name, render }) => render())
);
});
});
it('should validate on default usage', () => {
getStorybook().forEach(({ kind, stories }) =>
stories.forEach(({ name, render }) => render())
);
});
});
function getComponents() {
loadStories();
return getStorybook();
}
export default () => {
getStorybook().forEach(({ kind, stories }) => {
stories.forEach(({ name, render }) => {
storiesOf(`${kind}/RTL`, module)
.addDecorator(withServicesKnob({ defaultService: 'arabic' }))
.add(`RTL - ${name}`, render);
});
});
};
const getStorybookStories = ({ host, port }) =>
getStorybook().reduce(
(acc, { kind, stories }) =>
acc.concat(
stories.map(({ name }) => ({
kind: normalize(kind),
name: normalize(name),
url: createStoryURL({
query: createStoryQueryParameters(kind, name),
host,
port,
}),
}))
),
[]
);
function loadStories() {
require("../src/components/stories/tabs.js");
require("../src/components/stories/frames.js");
require("../src/components/stories/Preview.js");
require("../src/components/stories/Outline.js");
require("../src/components/stories/SearchInput.js");
require("../src/components/stories/ResultList.js");
require("../src/components/stories/ManagedTree.js");
require("../src/components/stories/Workers.js");
}
configure(loadStories, module);
if (typeof window === "object") {
window.__storybook_stories__ = getStorybook();
}