Norbert de Langen c2bbe43d02
stage0
2022-07-21 11:24:07 +02:00

32 lines
808 B
TypeScript

import type { Parameters } from '@storybook/addons';
// addons, panels and events get unique names using a prefix
export const PARAM_KEY = 'test';
export const ADDON_ID = 'storybookjs/test';
export const PANEL_ID = `${ADDON_ID}/panel`;
export const ADD_TESTS = `${ADDON_ID}/add_tests`;
interface AddonParameters extends Parameters {
jest?: string | string[] | { disabled: true };
}
export function defineJestParameter(parameters: AddonParameters): string[] | null {
const { jest, fileName: filePath } = parameters;
if (typeof jest === 'string') {
return [jest];
}
if (jest && Array.isArray(jest)) {
return jest;
}
if (jest === undefined && typeof filePath === 'string') {
const fileName = filePath.split('/').pop().split('.')[0];
return [fileName];
}
return null;
}