Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storybook/addon-jest

Package Overview
Dependencies
Maintainers
11
Versions
1920
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/addon-jest - npm Package Compare versions

Comparing version 0.0.0-pr-28800-sha-2528064a to 0.0.0-pr-28882-sha-2e6a0c80

10

dist/manager.js
import * as React5 from 'react';
import React5__default, { isValidElement, createRef, cloneElement, PureComponent, Fragment, useRef, useState, Component, useEffect, useLayoutEffect } from 'react';
import { addons, types } from 'storybook/internal/manager-api';
import 'tiny-invariant';
import { Placeholder, TabsState, ScrollArea, Link } from 'storybook/internal/components';
import { styled, convert, themes } from 'storybook/internal/theming';
import { Placeholder, TabsState, ScrollArea, Link } from 'storybook/internal/components';
import { findDOMNode } from 'react-dom';
import { STORY_CHANGED } from 'storybook/internal/core-events';
import 'tiny-invariant';
import { ChevronSmallDownIcon } from '@storybook/icons';
import { STORY_CHANGED } from 'storybook/internal/core-events';
var PARAM_KEY="test",ADDON_ID="storybookjs/test",PANEL_ID=`${ADDON_ID}/panel`,ADD_TESTS=`${ADDON_ID}/add_tests`;var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d2,b2){d2.__proto__=b2;}||function(d2,b2){for(var p in b2)Object.prototype.hasOwnProperty.call(b2,p)&&(d2[p]=b2[p]);},extendStatics(d,b)};function __extends(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d;}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __);}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);}return t},__assign.apply(this,arguments)};function __rest(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function isObject$3(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}var isObject_1=isObject$3,freeGlobal$1=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$2=freeGlobal||freeSelf||Function("return this")(),_root=root$2,root$1=_root,now$1=function(){return root$1.Date.now()},now_1=now$1,reWhitespace=/\s/;function trimmedEndIndex$1(string){for(var index=string.length;index--&&reWhitespace.test(string.charAt(index)););return index}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(string){return string&&string.slice(0,trimmedEndIndex(string)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,root=_root,Symbol$2=root.Symbol,_Symbol=Symbol$2,Symbol$1=_Symbol,objectProto$1=Object.prototype,hasOwnProperty=objectProto$1.hasOwnProperty,nativeObjectToString$1=objectProto$1.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag$1(value){var isOwn=hasOwnProperty.call(value,symToStringTag$1),tag=value[symToStringTag$1];try{value[symToStringTag$1]=void 0;var unmasked=!0;}catch{}var result=nativeObjectToString$1.call(value);return unmasked&&(isOwn?value[symToStringTag$1]=tag:delete value[symToStringTag$1]),result}var _getRawTag=getRawTag$1,objectProto=Object.prototype,nativeObjectToString=objectProto.toString;function objectToString$1(value){return nativeObjectToString.call(value)}var _objectToString=objectToString$1,Symbol=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol?Symbol.toStringTag:void 0;function baseGetTag$1(value){return value==null?value===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(value)?getRawTag(value):objectToString(value)}var _baseGetTag=baseGetTag$1;function isObjectLike$1(value){return value!=null&&typeof value=="object"}var isObjectLike_1=isObjectLike$1,baseGetTag=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$1(value){return typeof value=="symbol"||isObjectLike(value)&&baseGetTag(value)==symbolTag}var isSymbol_1=isSymbol$1,baseTrim=_baseTrim,isObject$2=isObject_1,isSymbol=isSymbol_1,NAN=NaN,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(value){if(typeof value=="number")return value;if(isSymbol(value))return NAN;if(isObject$2(value)){var other=typeof value.valueOf=="function"?value.valueOf():value;value=isObject$2(other)?other+"":other;}if(typeof value!="string")return value===0?value:+value;value=baseTrim(value);var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}var toNumber_1=toNumber$1,isObject$1=isObject_1,now=now_1,toNumber=toNumber_1,FUNC_ERROR_TEXT$1="Expected a function",nativeMax=Math.max,nativeMin=Math.min;function debounce$1(func,wait,options){var lastArgs,lastThis,maxWait,result,timerId,lastCallTime,lastInvokeTime=0,leading=!1,maxing=!1,trailing=!0;if(typeof func!="function")throw new TypeError(FUNC_ERROR_TEXT$1);wait=toNumber(wait)||0,isObject$1(options)&&(leading=!!options.leading,maxing="maxWait"in options,maxWait=maxing?nativeMax(toNumber(options.maxWait)||0,wait):maxWait,trailing="trailing"in options?!!options.trailing:trailing);function invokeFunc(time){var args=lastArgs,thisArg=lastThis;return lastArgs=lastThis=void 0,lastInvokeTime=time,result=func.apply(thisArg,args),result}function leadingEdge(time){return lastInvokeTime=time,timerId=setTimeout(timerExpired,wait),leading?invokeFunc(time):result}function remainingWait(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime,timeWaiting=wait-timeSinceLastCall;return maxing?nativeMin(timeWaiting,maxWait-timeSinceLastInvoke):timeWaiting}function shouldInvoke(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime;return lastCallTime===void 0||timeSinceLastCall>=wait||timeSinceLastCall<0||maxing&&timeSinceLastInvoke>=maxWait}function timerExpired(){var time=now();if(shouldInvoke(time))return trailingEdge(time);timerId=setTimeout(timerExpired,remainingWait(time));}function trailingEdge(time){return timerId=void 0,trailing&&lastArgs?invokeFunc(time):(lastArgs=lastThis=void 0,result)}function cancel(){timerId!==void 0&&clearTimeout(timerId),lastInvokeTime=0,lastArgs=lastCallTime=lastThis=timerId=void 0;}function flush(){return timerId===void 0?result:trailingEdge(now())}function debounced(){var time=now(),isInvoking=shouldInvoke(time);if(lastArgs=arguments,lastThis=this,lastCallTime=time,isInvoking){if(timerId===void 0)return leadingEdge(lastCallTime);if(maxing)return clearTimeout(timerId),timerId=setTimeout(timerExpired,wait),invokeFunc(lastCallTime)}return timerId===void 0&&(timerId=setTimeout(timerExpired,wait)),result}return debounced.cancel=cancel,debounced.flush=flush,debounced}var debounce_1=debounce$1,debounce=debounce_1,isObject=isObject_1,FUNC_ERROR_TEXT="Expected a function";function throttle(func,wait,options){var leading=!0,trailing=!0;if(typeof func!="function")throw new TypeError(FUNC_ERROR_TEXT);return isObject(options)&&(leading="leading"in options?!!options.leading:leading,trailing="trailing"in options?!!options.trailing:trailing),debounce(func,wait,{leading,maxWait:wait,trailing})}var throttle_1=throttle,patchResizeHandler=function(resizeCallback,refreshMode,refreshRate,refreshOptions){switch(refreshMode){case"debounce":return debounce_1(resizeCallback,refreshRate,refreshOptions);case"throttle":return throttle_1(resizeCallback,refreshRate,refreshOptions);default:return resizeCallback}},isFunction=function(fn){return typeof fn=="function"},isSSR=function(){return typeof window>"u"},isDOMElement=function(element){return element instanceof Element||element instanceof HTMLDocument},createNotifier=function(onResize,setSize,handleWidth,handleHeight){return function(_a){var width=_a.width,height=_a.height;setSize(function(prev){return prev.width===width&&prev.height===height||prev.width===width&&!handleHeight||prev.height===height&&!handleWidth?prev:(onResize&&isFunction(onResize)&&onResize(width,height),{width,height})});}};(function(_super){__extends(ResizeDetector2,_super);function ResizeDetector2(props){var _this=_super.call(this,props)||this;_this.cancelHandler=function(){_this.resizeHandler&&_this.resizeHandler.cancel&&(_this.resizeHandler.cancel(),_this.resizeHandler=null);},_this.attachObserver=function(){var _a2=_this.props,targetRef=_a2.targetRef,observerOptions=_a2.observerOptions;if(!isSSR()){targetRef&&targetRef.current&&(_this.targetRef.current=targetRef.current);var element=_this.getElement();element&&(_this.observableElement&&_this.observableElement===element||(_this.observableElement=element,_this.resizeObserver.observe(element,observerOptions)));}},_this.getElement=function(){var _a2=_this.props,querySelector=_a2.querySelector,targetDomEl=_a2.targetDomEl;if(isSSR())return null;if(querySelector)return document.querySelector(querySelector);if(targetDomEl&&isDOMElement(targetDomEl))return targetDomEl;if(_this.targetRef&&isDOMElement(_this.targetRef.current))return _this.targetRef.current;var currentElement=findDOMNode(_this);if(!currentElement)return null;var renderType=_this.getRenderType();switch(renderType){case"renderProp":return currentElement;case"childFunction":return currentElement;case"child":return currentElement;case"childArray":return currentElement;default:return currentElement.parentElement}},_this.createResizeHandler=function(entries){var _a2=_this.props,_b=_a2.handleWidth,handleWidth=_b===void 0?!0:_b,_c=_a2.handleHeight,handleHeight=_c===void 0?!0:_c,onResize=_a2.onResize;if(!(!handleWidth&&!handleHeight)){var notifyResize=createNotifier(onResize,_this.setState.bind(_this),handleWidth,handleHeight);entries.forEach(function(entry){var _a3=entry&&entry.contentRect||{},width=_a3.width,height=_a3.height,shouldSetSize=!_this.skipOnMount&&!isSSR();shouldSetSize&&notifyResize({width,height}),_this.skipOnMount=!1;});}},_this.getRenderType=function(){var _a2=_this.props,render=_a2.render,children=_a2.children;return isFunction(render)?"renderProp":isFunction(children)?"childFunction":isValidElement(children)?"child":Array.isArray(children)?"childArray":"parent"};var skipOnMount=props.skipOnMount,refreshMode=props.refreshMode,_a=props.refreshRate,refreshRate=_a===void 0?1e3:_a,refreshOptions=props.refreshOptions;return _this.state={width:void 0,height:void 0},_this.skipOnMount=skipOnMount,_this.targetRef=createRef(),_this.observableElement=null,isSSR()||(_this.resizeHandler=patchResizeHandler(_this.createResizeHandler,refreshMode,refreshRate,refreshOptions),_this.resizeObserver=new window.ResizeObserver(_this.resizeHandler)),_this}return ResizeDetector2.prototype.componentDidMount=function(){this.attachObserver();},ResizeDetector2.prototype.componentDidUpdate=function(){this.attachObserver();},ResizeDetector2.prototype.componentWillUnmount=function(){isSSR()||(this.observableElement=null,this.resizeObserver.disconnect(),this.cancelHandler());},ResizeDetector2.prototype.render=function(){var _a=this.props,render=_a.render,children=_a.children,_b=_a.nodeType,WrapperTag=_b===void 0?"div":_b,_c=this.state,width=_c.width,height=_c.height,childProps={width,height,targetRef:this.targetRef},renderType=this.getRenderType(),typedChildren;switch(renderType){case"renderProp":return render&&render(childProps);case"childFunction":return typedChildren=children,typedChildren(childProps);case"child":if(typedChildren=children,typedChildren.type&&typeof typedChildren.type=="string"){childProps.targetRef;var nativeProps=__rest(childProps,["targetRef"]);return cloneElement(typedChildren,nativeProps)}return cloneElement(typedChildren,childProps);case"childArray":return typedChildren=children,typedChildren.map(function(el){return !!el&&cloneElement(el,childProps)});default:return React5.createElement(WrapperTag,null)}},ResizeDetector2})(PureComponent);var useEnhancedEffect=isSSR()?useEffect:useLayoutEffect;function useResizeDetector(props){props===void 0&&(props={});var _a=props.skipOnMount,skipOnMount=_a===void 0?!1:_a,refreshMode=props.refreshMode,_b=props.refreshRate,refreshRate=_b===void 0?1e3:_b,refreshOptions=props.refreshOptions,_c=props.handleWidth,handleWidth=_c===void 0?!0:_c,_d=props.handleHeight,handleHeight=_d===void 0?!0:_d,targetRef=props.targetRef,observerOptions=props.observerOptions,onResize=props.onResize,skipResize=useRef(skipOnMount),localRef=useRef(null),ref=targetRef??localRef,resizeHandler=useRef(),_e=useState({width:void 0,height:void 0}),size=_e[0],setSize=_e[1];return useEnhancedEffect(function(){if(!isSSR()){var notifyResize=createNotifier(onResize,setSize,handleWidth,handleHeight),resizeCallback=function(entries){!handleWidth&&!handleHeight||entries.forEach(function(entry){var _a2=entry&&entry.contentRect||{},width=_a2.width,height=_a2.height,shouldSetSize=!skipResize.current&&!isSSR();shouldSetSize&&notifyResize({width,height}),skipResize.current=!1;});};resizeHandler.current=patchResizeHandler(resizeCallback,refreshMode,refreshRate,refreshOptions);var resizeObserver=new window.ResizeObserver(resizeHandler.current);return ref.current&&resizeObserver.observe(ref.current,observerOptions),function(){resizeObserver.disconnect();var patchedResizeHandler=resizeHandler.current;patchedResizeHandler&&patchedResizeHandler.cancel&&patchedResizeHandler.cancel();}}},[refreshMode,refreshRate,refreshOptions,handleWidth,handleHeight,onResize,observerOptions,ref.current]),__assign({ref},size)}var positiveConsoleRegex=/\[32m(.*?)\[39m/,negativeConsoleRegex=/\[31m(.*?)\[39m/,positiveType="positive",negativeType="negative",endToken="[39m",failStartToken="[31m",passStartToken="[32m",stackTraceStartToken="at",titleEndToken=":",TestDetail=class{},StackTrace=styled.pre(({theme})=>({background:theme.color.lighter,paddingTop:4,paddingBottom:4,paddingLeft:6,borderRadius:2,overflow:"auto",margin:"10px 30px 10px 30px",whiteSpace:"pre"})),Results=styled.div({paddingTop:10,marginLeft:31,marginRight:30}),Description=styled.div(({theme})=>({paddingBottom:10,paddingTop:10,borderBottom:theme.appBorderColor,marginLeft:31,marginRight:30,overflowWrap:"break-word"})),StatusColor=styled.strong(({status,theme})=>({color:status===positiveType?theme.color.positive:theme.color.negative,fontWeight:500})),colorizeText=(msg,type)=>type?msg.split(type===positiveType?positiveConsoleRegex:negativeConsoleRegex).map((i,index)=>index%2?React5__default.createElement(StatusColor,{key:`${type}_${i}`,status:type},i):i):[msg],getConvertedText=msg=>{let elementArray=[];return msg&&msg.split(/\[2m/).join("").split(/\[22m/).forEach(element=>{element&&element.trim()&&(element.indexOf(failStartToken)>-1&&element.indexOf(failStartToken)<element.indexOf(endToken)?elementArray=elementArray.concat(colorizeText(element,negativeType)):element.indexOf(passStartToken)>-1&&element.indexOf(passStartToken)<element.indexOf(endToken)?elementArray=elementArray.concat(colorizeText(element,positiveType)):elementArray=elementArray.concat(element));}),elementArray},getTestDetail=msg=>{let lines=msg.split(`
var extendStatics=function(d,b){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d2,b2){d2.__proto__=b2;}||function(d2,b2){for(var p in b2)Object.prototype.hasOwnProperty.call(b2,p)&&(d2[p]=b2[p]);},extendStatics(d,b)};function __extends(d,b){if(typeof b!="function"&&b!==null)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");extendStatics(d,b);function __(){this.constructor=d;}d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __);}var __assign=function(){return __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);}return t},__assign.apply(this,arguments)};function __rest(s,e){var t={};for(var p in s)Object.prototype.hasOwnProperty.call(s,p)&&e.indexOf(p)<0&&(t[p]=s[p]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,p=Object.getOwnPropertySymbols(s);i<p.length;i++)e.indexOf(p[i])<0&&Object.prototype.propertyIsEnumerable.call(s,p[i])&&(t[p[i]]=s[p[i]]);return t}var commonjsGlobal=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function isObject$3(value){var type=typeof value;return value!=null&&(type=="object"||type=="function")}var isObject_1=isObject$3,freeGlobal$1=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$2=freeGlobal||freeSelf||Function("return this")(),_root=root$2,root$1=_root,now$1=function(){return root$1.Date.now()},now_1=now$1,reWhitespace=/\s/;function trimmedEndIndex$1(string){for(var index=string.length;index--&&reWhitespace.test(string.charAt(index)););return index}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(string){return string&&string.slice(0,trimmedEndIndex(string)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,root=_root,Symbol$2=root.Symbol,_Symbol=Symbol$2,Symbol$1=_Symbol,objectProto$1=Object.prototype,hasOwnProperty=objectProto$1.hasOwnProperty,nativeObjectToString$1=objectProto$1.toString,symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;function getRawTag$1(value){var isOwn=hasOwnProperty.call(value,symToStringTag$1),tag=value[symToStringTag$1];try{value[symToStringTag$1]=void 0;var unmasked=!0;}catch{}var result=nativeObjectToString$1.call(value);return unmasked&&(isOwn?value[symToStringTag$1]=tag:delete value[symToStringTag$1]),result}var _getRawTag=getRawTag$1,objectProto=Object.prototype,nativeObjectToString=objectProto.toString;function objectToString$1(value){return nativeObjectToString.call(value)}var _objectToString=objectToString$1,Symbol=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol?Symbol.toStringTag:void 0;function baseGetTag$1(value){return value==null?value===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(value)?getRawTag(value):objectToString(value)}var _baseGetTag=baseGetTag$1;function isObjectLike$1(value){return value!=null&&typeof value=="object"}var isObjectLike_1=isObjectLike$1,baseGetTag=_baseGetTag,isObjectLike=isObjectLike_1,symbolTag="[object Symbol]";function isSymbol$1(value){return typeof value=="symbol"||isObjectLike(value)&&baseGetTag(value)==symbolTag}var isSymbol_1=isSymbol$1,baseTrim=_baseTrim,isObject$2=isObject_1,isSymbol=isSymbol_1,NAN=NaN,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(value){if(typeof value=="number")return value;if(isSymbol(value))return NAN;if(isObject$2(value)){var other=typeof value.valueOf=="function"?value.valueOf():value;value=isObject$2(other)?other+"":other;}if(typeof value!="string")return value===0?value:+value;value=baseTrim(value);var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NAN:+value}var toNumber_1=toNumber$1,isObject$1=isObject_1,now=now_1,toNumber=toNumber_1,FUNC_ERROR_TEXT$1="Expected a function",nativeMax=Math.max,nativeMin=Math.min;function debounce$1(func,wait,options){var lastArgs,lastThis,maxWait,result,timerId,lastCallTime,lastInvokeTime=0,leading=!1,maxing=!1,trailing=!0;if(typeof func!="function")throw new TypeError(FUNC_ERROR_TEXT$1);wait=toNumber(wait)||0,isObject$1(options)&&(leading=!!options.leading,maxing="maxWait"in options,maxWait=maxing?nativeMax(toNumber(options.maxWait)||0,wait):maxWait,trailing="trailing"in options?!!options.trailing:trailing);function invokeFunc(time){var args=lastArgs,thisArg=lastThis;return lastArgs=lastThis=void 0,lastInvokeTime=time,result=func.apply(thisArg,args),result}function leadingEdge(time){return lastInvokeTime=time,timerId=setTimeout(timerExpired,wait),leading?invokeFunc(time):result}function remainingWait(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime,timeWaiting=wait-timeSinceLastCall;return maxing?nativeMin(timeWaiting,maxWait-timeSinceLastInvoke):timeWaiting}function shouldInvoke(time){var timeSinceLastCall=time-lastCallTime,timeSinceLastInvoke=time-lastInvokeTime;return lastCallTime===void 0||timeSinceLastCall>=wait||timeSinceLastCall<0||maxing&&timeSinceLastInvoke>=maxWait}function timerExpired(){var time=now();if(shouldInvoke(time))return trailingEdge(time);timerId=setTimeout(timerExpired,remainingWait(time));}function trailingEdge(time){return timerId=void 0,trailing&&lastArgs?invokeFunc(time):(lastArgs=lastThis=void 0,result)}function cancel(){timerId!==void 0&&clearTimeout(timerId),lastInvokeTime=0,lastArgs=lastCallTime=lastThis=timerId=void 0;}function flush(){return timerId===void 0?result:trailingEdge(now())}function debounced(){var time=now(),isInvoking=shouldInvoke(time);if(lastArgs=arguments,lastThis=this,lastCallTime=time,isInvoking){if(timerId===void 0)return leadingEdge(lastCallTime);if(maxing)return clearTimeout(timerId),timerId=setTimeout(timerExpired,wait),invokeFunc(lastCallTime)}return timerId===void 0&&(timerId=setTimeout(timerExpired,wait)),result}return debounced.cancel=cancel,debounced.flush=flush,debounced}var debounce_1=debounce$1,debounce=debounce_1,isObject=isObject_1,FUNC_ERROR_TEXT="Expected a function";function throttle(func,wait,options){var leading=!0,trailing=!0;if(typeof func!="function")throw new TypeError(FUNC_ERROR_TEXT);return isObject(options)&&(leading="leading"in options?!!options.leading:leading,trailing="trailing"in options?!!options.trailing:trailing),debounce(func,wait,{leading,maxWait:wait,trailing})}var throttle_1=throttle,patchResizeHandler=function(resizeCallback,refreshMode,refreshRate,refreshOptions){switch(refreshMode){case"debounce":return debounce_1(resizeCallback,refreshRate,refreshOptions);case"throttle":return throttle_1(resizeCallback,refreshRate,refreshOptions);default:return resizeCallback}},isFunction=function(fn){return typeof fn=="function"},isSSR=function(){return typeof window>"u"},isDOMElement=function(element){return element instanceof Element||element instanceof HTMLDocument},createNotifier=function(onResize,setSize,handleWidth,handleHeight){return function(_a){var width=_a.width,height=_a.height;setSize(function(prev){return prev.width===width&&prev.height===height||prev.width===width&&!handleHeight||prev.height===height&&!handleWidth?prev:(onResize&&isFunction(onResize)&&onResize(width,height),{width,height})});}};(function(_super){__extends(ResizeDetector2,_super);function ResizeDetector2(props){var _this=_super.call(this,props)||this;_this.cancelHandler=function(){_this.resizeHandler&&_this.resizeHandler.cancel&&(_this.resizeHandler.cancel(),_this.resizeHandler=null);},_this.attachObserver=function(){var _a2=_this.props,targetRef=_a2.targetRef,observerOptions=_a2.observerOptions;if(!isSSR()){targetRef&&targetRef.current&&(_this.targetRef.current=targetRef.current);var element=_this.getElement();element&&(_this.observableElement&&_this.observableElement===element||(_this.observableElement=element,_this.resizeObserver.observe(element,observerOptions)));}},_this.getElement=function(){var _a2=_this.props,querySelector=_a2.querySelector,targetDomEl=_a2.targetDomEl;if(isSSR())return null;if(querySelector)return document.querySelector(querySelector);if(targetDomEl&&isDOMElement(targetDomEl))return targetDomEl;if(_this.targetRef&&isDOMElement(_this.targetRef.current))return _this.targetRef.current;var currentElement=findDOMNode(_this);if(!currentElement)return null;var renderType=_this.getRenderType();switch(renderType){case"renderProp":return currentElement;case"childFunction":return currentElement;case"child":return currentElement;case"childArray":return currentElement;default:return currentElement.parentElement}},_this.createResizeHandler=function(entries){var _a2=_this.props,_b=_a2.handleWidth,handleWidth=_b===void 0?!0:_b,_c=_a2.handleHeight,handleHeight=_c===void 0?!0:_c,onResize=_a2.onResize;if(!(!handleWidth&&!handleHeight)){var notifyResize=createNotifier(onResize,_this.setState.bind(_this),handleWidth,handleHeight);entries.forEach(function(entry){var _a3=entry&&entry.contentRect||{},width=_a3.width,height=_a3.height,shouldSetSize=!_this.skipOnMount&&!isSSR();shouldSetSize&&notifyResize({width,height}),_this.skipOnMount=!1;});}},_this.getRenderType=function(){var _a2=_this.props,render=_a2.render,children=_a2.children;return isFunction(render)?"renderProp":isFunction(children)?"childFunction":isValidElement(children)?"child":Array.isArray(children)?"childArray":"parent"};var skipOnMount=props.skipOnMount,refreshMode=props.refreshMode,_a=props.refreshRate,refreshRate=_a===void 0?1e3:_a,refreshOptions=props.refreshOptions;return _this.state={width:void 0,height:void 0},_this.skipOnMount=skipOnMount,_this.targetRef=createRef(),_this.observableElement=null,isSSR()||(_this.resizeHandler=patchResizeHandler(_this.createResizeHandler,refreshMode,refreshRate,refreshOptions),_this.resizeObserver=new window.ResizeObserver(_this.resizeHandler)),_this}return ResizeDetector2.prototype.componentDidMount=function(){this.attachObserver();},ResizeDetector2.prototype.componentDidUpdate=function(){this.attachObserver();},ResizeDetector2.prototype.componentWillUnmount=function(){isSSR()||(this.observableElement=null,this.resizeObserver.disconnect(),this.cancelHandler());},ResizeDetector2.prototype.render=function(){var _a=this.props,render=_a.render,children=_a.children,_b=_a.nodeType,WrapperTag=_b===void 0?"div":_b,_c=this.state,width=_c.width,height=_c.height,childProps={width,height,targetRef:this.targetRef},renderType=this.getRenderType(),typedChildren;switch(renderType){case"renderProp":return render&&render(childProps);case"childFunction":return typedChildren=children,typedChildren(childProps);case"child":if(typedChildren=children,typedChildren.type&&typeof typedChildren.type=="string"){childProps.targetRef;var nativeProps=__rest(childProps,["targetRef"]);return cloneElement(typedChildren,nativeProps)}return cloneElement(typedChildren,childProps);case"childArray":return typedChildren=children,typedChildren.map(function(el){return !!el&&cloneElement(el,childProps)});default:return React5.createElement(WrapperTag,null)}},ResizeDetector2})(PureComponent);var useEnhancedEffect=isSSR()?useEffect:useLayoutEffect;function useResizeDetector(props){props===void 0&&(props={});var _a=props.skipOnMount,skipOnMount=_a===void 0?!1:_a,refreshMode=props.refreshMode,_b=props.refreshRate,refreshRate=_b===void 0?1e3:_b,refreshOptions=props.refreshOptions,_c=props.handleWidth,handleWidth=_c===void 0?!0:_c,_d=props.handleHeight,handleHeight=_d===void 0?!0:_d,targetRef=props.targetRef,observerOptions=props.observerOptions,onResize=props.onResize,skipResize=useRef(skipOnMount),localRef=useRef(null),ref=targetRef??localRef,resizeHandler=useRef(),_e=useState({width:void 0,height:void 0}),size=_e[0],setSize=_e[1];return useEnhancedEffect(function(){if(!isSSR()){var notifyResize=createNotifier(onResize,setSize,handleWidth,handleHeight),resizeCallback=function(entries){!handleWidth&&!handleHeight||entries.forEach(function(entry){var _a2=entry&&entry.contentRect||{},width=_a2.width,height=_a2.height,shouldSetSize=!skipResize.current&&!isSSR();shouldSetSize&&notifyResize({width,height}),skipResize.current=!1;});};resizeHandler.current=patchResizeHandler(resizeCallback,refreshMode,refreshRate,refreshOptions);var resizeObserver=new window.ResizeObserver(resizeHandler.current);return ref.current&&resizeObserver.observe(ref.current,observerOptions),function(){resizeObserver.disconnect();var patchedResizeHandler=resizeHandler.current;patchedResizeHandler&&patchedResizeHandler.cancel&&patchedResizeHandler.cancel();}}},[refreshMode,refreshRate,refreshOptions,handleWidth,handleHeight,onResize,observerOptions,ref.current]),__assign({ref},size)}var PARAM_KEY="test",ADDON_ID="storybookjs/test",PANEL_ID=`${ADDON_ID}/panel`,ADD_TESTS=`${ADDON_ID}/add_tests`;var provideTests=Component2=>{var _a;return _a=class extends Component{constructor(){super(...arguments);this.state={};this.onAddTests=({kind,storyName,tests})=>{this.setState({kind,storyName,tests});};}componentDidMount(){this.mounted=!0;let{api}=this.props;this.stopListeningOnStory=api.on(STORY_CHANGED,()=>{let{kind,storyName,tests}=this.state;this.mounted&&(kind||storyName||tests)&&this.onAddTests({});}),api.on(ADD_TESTS,this.onAddTests);}componentWillUnmount(){this.mounted=!1;let{api}=this.props;this.stopListeningOnStory(),api.off(ADD_TESTS,this.onAddTests);}render(){let{active}=this.props,{tests}=this.state;return active?React5__default.createElement(Component2,{tests}):null}},_a.defaultProps={active:!1},_a};var positiveConsoleRegex=/\[32m(.*?)\[39m/,negativeConsoleRegex=/\[31m(.*?)\[39m/,positiveType="positive",negativeType="negative",endToken="[39m",failStartToken="[31m",passStartToken="[32m",stackTraceStartToken="at",titleEndToken=":",TestDetail=class{},StackTrace=styled.pre(({theme})=>({background:theme.color.lighter,paddingTop:4,paddingBottom:4,paddingLeft:6,borderRadius:2,overflow:"auto",margin:"10px 30px 10px 30px",whiteSpace:"pre"})),Results=styled.div({paddingTop:10,marginLeft:31,marginRight:30}),Description=styled.div(({theme})=>({paddingBottom:10,paddingTop:10,borderBottom:theme.appBorderColor,marginLeft:31,marginRight:30,overflowWrap:"break-word"})),StatusColor=styled.strong(({status,theme})=>({color:status===positiveType?theme.color.positive:theme.color.negative,fontWeight:500})),colorizeText=(msg,type)=>type?msg.split(type===positiveType?positiveConsoleRegex:negativeConsoleRegex).map((i,index)=>index%2?React5__default.createElement(StatusColor,{key:`${type}_${i}`,status:type},i):i):[msg],getConvertedText=msg=>{let elementArray=[];return msg&&msg.split(/\[2m/).join("").split(/\[22m/).forEach(element=>{element&&element.trim()&&(element.indexOf(failStartToken)>-1&&element.indexOf(failStartToken)<element.indexOf(endToken)?elementArray=elementArray.concat(colorizeText(element,negativeType)):element.indexOf(passStartToken)>-1&&element.indexOf(passStartToken)<element.indexOf(endToken)?elementArray=elementArray.concat(colorizeText(element,positiveType)):elementArray=elementArray.concat(element));}),elementArray},getTestDetail=msg=>{let lines=msg.split(`
`).filter(Boolean),testDetail=new TestDetail;testDetail.description=getConvertedText(lines[0]),testDetail.stackTrace="",testDetail.result=[];for(let index=1;index<lines.length;index+=1){let current=lines[index],next=lines[index+1];if(current.trim().toLowerCase().indexOf(stackTraceStartToken)===0)testDetail.stackTrace+=`${current.trim()}
`;else if(current.trim().indexOf(titleEndToken)>-1){let title,value=null;current.trim().indexOf(titleEndToken)===current.length-1?(title=current.trim(),value=getConvertedText(next),index+=1):(title=current.substring(0,current.indexOf(titleEndToken)).trim(),value=getConvertedText(current.substring(current.indexOf(titleEndToken),current.length))),testDetail.result=[...testDetail.result,title," ",...value,React5__default.createElement("br",{key:index})];}else testDetail.result=[...testDetail.result," ",...getConvertedText(current)];}return testDetail},Message=props=>{let{msg}=props,detail=getTestDetail(msg);return React5__default.createElement(Fragment,null,detail.description?React5__default.createElement(Description,null,detail.description):null,detail.result?React5__default.createElement(Results,null,detail.result):null,detail.stackTrace?React5__default.createElement(StackTrace,null,detail.stackTrace):null)},Message_default=Message;var Wrapper=styled.div(({theme,status})=>({display:"flex",width:"100%",borderTop:`1px solid ${theme.appBorderColor}`,"&:hover":{background:status==="failed"?theme.background.hoverable:void 0}})),HeaderBar=styled.div(({theme,status})=>({padding:theme.layoutMargin,paddingLeft:theme.layoutMargin-3,background:"none",color:"inherit",textAlign:"left",cursor:status==="failed"?"pointer":void 0,borderLeft:"3px solid transparent",width:"100%",display:"flex","&:focus":{outline:"0 none",borderLeft:`3px solid ${theme.color.secondary}`}})),Icon=styled(ChevronSmallDownIcon)(({theme})=>({color:theme.textMutedColor,marginRight:10,transition:"transform 0.1s ease-in-out",alignSelf:"center",display:"inline-flex"})),capitalizeFirstLetter=text=>text.charAt(0).toUpperCase().concat(text.slice(1));function Result(props){let[isOpen,setIsOpen]=useState(!1),onToggle=()=>{setIsOpen(!isOpen);},{fullName,title,failureMessages,status}=props;return React5__default.createElement(Fragment,null,React5__default.createElement(Wrapper,{status},React5__default.createElement(HeaderBar,{onClick:onToggle,role:"button",status},status==="failed"?React5__default.createElement(Icon,{color:convert(themes.light).textMutedColor,style:{transform:`rotate(${isOpen?0:-90}deg)`}}):null,React5__default.createElement("div",null,capitalizeFirstLetter(fullName??"")||capitalizeFirstLetter(title??"")))),isOpen?React5__default.createElement(Fragment,null,failureMessages.map((msg,i)=>React5__default.createElement(Message_default,{msg,key:i}))):null)}var provideTests=Component2=>{var _a;return _a=class extends Component{constructor(){super(...arguments);this.state={};this.onAddTests=({kind,storyName,tests})=>{this.setState({kind,storyName,tests});};}componentDidMount(){this.mounted=!0;let{api}=this.props;this.stopListeningOnStory=api.on(STORY_CHANGED,()=>{let{kind,storyName,tests}=this.state;this.mounted&&(kind||storyName||tests)&&this.onAddTests({});}),api.on(ADD_TESTS,this.onAddTests);}componentWillUnmount(){this.mounted=!1;let{api}=this.props;this.stopListeningOnStory(),api.off(ADD_TESTS,this.onAddTests);}render(){let{active}=this.props,{tests}=this.state;return active?React5__default.createElement(Component2,{tests}):null}},_a.defaultProps={active:!1},_a};var StatusTypes={PASSED_TYPE:"passed",FAILED_TYPE:"failed",PENDING_TYPE:"pending",TODO_TYPE:"todo"},List=styled.ul({listStyle:"none",fontSize:14,padding:0,margin:0}),Item=styled.li({display:"block",padding:0}),ProgressWrapper=styled.div({position:"relative",height:10,width:30,display:"flex",top:-2}),SuiteHead=styled.div({display:"flex",alignItems:"baseline",position:"absolute",zIndex:2,right:20,marginTop:15}),UnstyledSuiteTotals=({result,className,width})=>React5__default.createElement("div",{className},React5__default.createElement(Fragment,null,width>325&&result.assertionResults?React5__default.createElement("div",null,result.assertionResults.length," ",result.assertionResults.length>1?"tests":"test"):null,width>280&&result.endTime&&result.startTime?React5__default.createElement("div",null,result.endTime-result.startTime,"ms"):null)),SuiteTotals=styled(UnstyledSuiteTotals)(({theme})=>({display:"flex",alignItems:"center",color:theme.color.dark,fontSize:"14px",marginTop:-5,"& > *":{marginRight:10}})),SuiteProgressPortion=styled.div(({color,progressPercent})=>({height:6,top:3,width:`${progressPercent}%`,backgroundColor:color})),getTestsByTypeMap=result=>{let testsByType=new Map;return result.assertionResults.forEach(assertion=>{testsByType.set(assertion.status,testsByType.get(assertion.status)?testsByType.get(assertion.status).concat(assertion):[assertion]);}),testsByType},getColorByType=type=>{switch(type){case StatusTypes.PASSED_TYPE:return convert(themes.light).color.positive;case StatusTypes.FAILED_TYPE:return convert(themes.light).color.negative;case StatusTypes.PENDING_TYPE:return convert(themes.light).color.warning;case StatusTypes.TODO_TYPE:return convert(themes.light).color.purple;default:return}},TestPanel=({test})=>{let{ref,width}=useResizeDetector(),{result}=test;if(!result||!result.assertionResults)return React5__default.createElement(Placeholder,null,"This story has tests configured, but no file was found");let testsByType=getTestsByTypeMap(result),sortedTestsByCount=[...testsByType.entries()].sort((a,b)=>a[1].length-b[1].length);return React5__default.createElement("section",{ref},React5__default.createElement(SuiteHead,null,React5__default.createElement(SuiteTotals,{result,width:width??0}),width!=null&&width>240?React5__default.createElement(ProgressWrapper,null,sortedTestsByCount.map(entry=>React5__default.createElement(SuiteProgressPortion,{key:`progress-portion-${entry[0]}`,color:getColorByType(entry[0]),progressPercent:entry[1]?entry[1].length/result.assertionResults.length*100:0}))):null),React5__default.createElement(TabsState,{initial:"failing-tests",backgroundColor:convert(themes.light).background.hoverable},React5__default.createElement("div",{id:"failing-tests",title:`${testsByType.get(StatusTypes.FAILED_TYPE)?testsByType.get(StatusTypes.FAILED_TYPE).length:0} Failed`,color:getColorByType(StatusTypes.FAILED_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.FAILED_TYPE)?testsByType.get(StatusTypes.FAILED_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.FAILED_TYPE}`},"This story has no failing tests."))),React5__default.createElement("div",{id:"passing-tests",title:`${testsByType.get(StatusTypes.PASSED_TYPE)?testsByType.get(StatusTypes.PASSED_TYPE).length:0} Passed`,color:getColorByType(StatusTypes.PASSED_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.PASSED_TYPE)?testsByType.get(StatusTypes.PASSED_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.PASSED_TYPE}`},"This story has no passing tests."))),React5__default.createElement("div",{id:"pending-tests",title:`${testsByType.get(StatusTypes.PENDING_TYPE)?testsByType.get(StatusTypes.PENDING_TYPE).length:0} Pending`,color:getColorByType(StatusTypes.PENDING_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.PENDING_TYPE)?testsByType.get(StatusTypes.PENDING_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.PENDING_TYPE}`},"This story has no pending tests."))),React5__default.createElement("div",{id:"todo-tests",title:`${testsByType.get(StatusTypes.TODO_TYPE)?testsByType.get(StatusTypes.TODO_TYPE).length:0} Todo`,color:getColorByType(StatusTypes.TODO_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.TODO_TYPE)?testsByType.get(StatusTypes.TODO_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.TODO_TYPE}`},"This story has no tests todo.")))))},Content=styled(({tests,className})=>React5__default.createElement("div",{className},tests.map(test=>React5__default.createElement(TestPanel,{key:test.name,test}))))({flex:"1 1 0%"}),Panel=({tests})=>React5__default.createElement(ScrollArea,{vertical:!0},tests?React5__default.createElement(Content,{tests}):React5__default.createElement(Placeholder,null,React5__default.createElement(Fragment,null,"No tests found"),React5__default.createElement(Fragment,null,"Learn how to\xA0",React5__default.createElement(Link,{href:"https://github.com/storybookjs/storybook/tree/master/addons/jest",target:"_blank",withArrow:!0},"add Jest test results to your story"))));Panel.defaultProps={tests:void 0};var Panel_default=provideTests(Panel);addons.register(ADDON_ID,api=>{addons.add(PANEL_ID,{title:"Tests",type:types.PANEL,render:({active})=>React5.createElement(Panel_default,{api,active}),paramKey:PARAM_KEY});});
`;else if(current.trim().indexOf(titleEndToken)>-1){let title,value=null;current.trim().indexOf(titleEndToken)===current.length-1?(title=current.trim(),value=getConvertedText(next),index+=1):(title=current.substring(0,current.indexOf(titleEndToken)).trim(),value=getConvertedText(current.substring(current.indexOf(titleEndToken),current.length))),testDetail.result=[...testDetail.result,title," ",...value,React5__default.createElement("br",{key:index})];}else testDetail.result=[...testDetail.result," ",...getConvertedText(current)];}return testDetail},Message=props=>{let{msg}=props,detail=getTestDetail(msg);return React5__default.createElement(Fragment,null,detail.description?React5__default.createElement(Description,null,detail.description):null,detail.result?React5__default.createElement(Results,null,detail.result):null,detail.stackTrace?React5__default.createElement(StackTrace,null,detail.stackTrace):null)},Message_default=Message;var Wrapper=styled.div(({theme,status})=>({display:"flex",width:"100%",borderTop:`1px solid ${theme.appBorderColor}`,"&:hover":{background:status==="failed"?theme.background.hoverable:void 0}})),HeaderBar=styled.div(({theme,status})=>({padding:theme.layoutMargin,paddingLeft:theme.layoutMargin-3,background:"none",color:"inherit",textAlign:"left",cursor:status==="failed"?"pointer":void 0,borderLeft:"3px solid transparent",width:"100%",display:"flex","&:focus":{outline:"0 none",borderLeft:`3px solid ${theme.color.secondary}`}})),Icon=styled(ChevronSmallDownIcon)(({theme})=>({color:theme.textMutedColor,marginRight:10,transition:"transform 0.1s ease-in-out",alignSelf:"center",display:"inline-flex"})),capitalizeFirstLetter=text=>text.charAt(0).toUpperCase().concat(text.slice(1));function Result(props){let[isOpen,setIsOpen]=useState(!1),onToggle=()=>{setIsOpen(!isOpen);},{fullName,title,failureMessages,status}=props;return React5__default.createElement(Fragment,null,React5__default.createElement(Wrapper,{status},React5__default.createElement(HeaderBar,{onClick:onToggle,role:"button",status},status==="failed"?React5__default.createElement(Icon,{color:convert(themes.light).textMutedColor,style:{transform:`rotate(${isOpen?0:-90}deg)`}}):null,React5__default.createElement("div",null,capitalizeFirstLetter(fullName??"")||capitalizeFirstLetter(title??"")))),isOpen?React5__default.createElement(Fragment,null,failureMessages.map((msg,i)=>React5__default.createElement(Message_default,{msg,key:i}))):null)}var StatusTypes={PASSED_TYPE:"passed",FAILED_TYPE:"failed",PENDING_TYPE:"pending",TODO_TYPE:"todo"},List=styled.ul({listStyle:"none",fontSize:14,padding:0,margin:0}),Item=styled.li({display:"block",padding:0}),ProgressWrapper=styled.div({position:"relative",height:10,width:30,display:"flex",top:-2}),SuiteHead=styled.div({display:"flex",alignItems:"baseline",position:"absolute",zIndex:2,right:20,marginTop:15}),UnstyledSuiteTotals=({result,className,width})=>React5__default.createElement("div",{className},React5__default.createElement(Fragment,null,width>325&&result.assertionResults?React5__default.createElement("div",null,result.assertionResults.length," ",result.assertionResults.length>1?"tests":"test"):null,width>280&&result.endTime&&result.startTime?React5__default.createElement("div",null,result.endTime-result.startTime,"ms"):null)),SuiteTotals=styled(UnstyledSuiteTotals)(({theme})=>({display:"flex",alignItems:"center",color:theme.color.dark,fontSize:"14px",marginTop:-5,"& > *":{marginRight:10}})),SuiteProgressPortion=styled.div(({color,progressPercent})=>({height:6,top:3,width:`${progressPercent}%`,backgroundColor:color})),getTestsByTypeMap=result=>{let testsByType=new Map;return result.assertionResults.forEach(assertion=>{testsByType.set(assertion.status,testsByType.get(assertion.status)?testsByType.get(assertion.status).concat(assertion):[assertion]);}),testsByType},getColorByType=type=>{switch(type){case StatusTypes.PASSED_TYPE:return convert(themes.light).color.positive;case StatusTypes.FAILED_TYPE:return convert(themes.light).color.negative;case StatusTypes.PENDING_TYPE:return convert(themes.light).color.warning;case StatusTypes.TODO_TYPE:return convert(themes.light).color.purple;default:return}},TestPanel=({test})=>{let{ref,width}=useResizeDetector(),{result}=test;if(!result||!result.assertionResults)return React5__default.createElement(Placeholder,null,"This story has tests configured, but no file was found");let testsByType=getTestsByTypeMap(result),sortedTestsByCount=[...testsByType.entries()].sort((a,b)=>a[1].length-b[1].length);return React5__default.createElement("section",{ref},React5__default.createElement(SuiteHead,null,React5__default.createElement(SuiteTotals,{result,width:width??0}),width!=null&&width>240?React5__default.createElement(ProgressWrapper,null,sortedTestsByCount.map(entry=>React5__default.createElement(SuiteProgressPortion,{key:`progress-portion-${entry[0]}`,color:getColorByType(entry[0]),progressPercent:entry[1]?entry[1].length/result.assertionResults.length*100:0}))):null),React5__default.createElement(TabsState,{initial:"failing-tests",backgroundColor:convert(themes.light).background.hoverable},React5__default.createElement("div",{id:"failing-tests",title:`${testsByType.get(StatusTypes.FAILED_TYPE)?testsByType.get(StatusTypes.FAILED_TYPE).length:0} Failed`,color:getColorByType(StatusTypes.FAILED_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.FAILED_TYPE)?testsByType.get(StatusTypes.FAILED_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.FAILED_TYPE}`},"This story has no failing tests."))),React5__default.createElement("div",{id:"passing-tests",title:`${testsByType.get(StatusTypes.PASSED_TYPE)?testsByType.get(StatusTypes.PASSED_TYPE).length:0} Passed`,color:getColorByType(StatusTypes.PASSED_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.PASSED_TYPE)?testsByType.get(StatusTypes.PASSED_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.PASSED_TYPE}`},"This story has no passing tests."))),React5__default.createElement("div",{id:"pending-tests",title:`${testsByType.get(StatusTypes.PENDING_TYPE)?testsByType.get(StatusTypes.PENDING_TYPE).length:0} Pending`,color:getColorByType(StatusTypes.PENDING_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.PENDING_TYPE)?testsByType.get(StatusTypes.PENDING_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.PENDING_TYPE}`},"This story has no pending tests."))),React5__default.createElement("div",{id:"todo-tests",title:`${testsByType.get(StatusTypes.TODO_TYPE)?testsByType.get(StatusTypes.TODO_TYPE).length:0} Todo`,color:getColorByType(StatusTypes.TODO_TYPE)},React5__default.createElement(List,null,testsByType.get(StatusTypes.TODO_TYPE)?testsByType.get(StatusTypes.TODO_TYPE).map(res=>React5__default.createElement(Item,{key:res.fullName||res.title},React5__default.createElement(Result,{...res}))):React5__default.createElement(Placeholder,{key:`no-tests-${StatusTypes.TODO_TYPE}`},"This story has no tests todo.")))))},Content=styled(({tests,className})=>React5__default.createElement("div",{className},tests.map(test=>React5__default.createElement(TestPanel,{key:test.name,test}))))({flex:"1 1 0%"}),Panel=({tests})=>React5__default.createElement(ScrollArea,{vertical:!0},tests?React5__default.createElement(Content,{tests}):React5__default.createElement(Placeholder,null,React5__default.createElement(Fragment,null,"No tests found"),React5__default.createElement(Fragment,null,"Learn how to\xA0",React5__default.createElement(Link,{href:"https://github.com/storybookjs/storybook/tree/master/addons/jest",target:"_blank",withArrow:!0},"add Jest test results to your story"))));Panel.defaultProps={tests:void 0};var Panel_default=provideTests(Panel);addons.register(ADDON_ID,api=>{addons.add(PANEL_ID,{title:"Tests",type:types.PANEL,render:({active})=>React5.createElement(Panel_default,{api,active}),paramKey:PARAM_KEY});});
{
"name": "@storybook/addon-jest",
"version": "0.0.0-pr-28800-sha-2528064a",
"version": "0.0.0-pr-28882-sha-2e6a0c80",
"description": "React storybook addon that show component jest report",

@@ -33,5 +33,5 @@ "keywords": [

"types": "./dist/index.d.ts",
"node": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"require": "./dist/index.js",
"node": "./dist/index.js"
},

@@ -53,4 +53,4 @@ "./manager": "./dist/manager.js",

"scripts": {
"check": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/check.ts",
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/addon-bundle.ts"
"check": "jiti ../../../scripts/prepare/check.ts",
"prep": "jiti ../../../scripts/prepare/addon-bundle.ts"
},

@@ -64,3 +64,3 @@ "dependencies": {

"devDependencies": {
"@storybook/icons": "^1.2.5",
"@storybook/icons": "^1.2.10",
"react": "^18.2.0",

@@ -72,3 +72,3 @@ "react-dom": "^18.2.0",

"peerDependencies": {
"storybook": "^0.0.0-pr-28800-sha-2528064a"
"storybook": "^0.0.0-pr-28882-sha-2e6a0c80"
},

@@ -75,0 +75,0 @@ "publishConfig": {

@@ -91,9 +91,6 @@ # Storybook addon Jest

// MyComponent.stories.js|jsx
import { withTests } from '@storybook/addon-jest';
import results from '../.jest-test-results.json';
import MyComponent from './MyComponent';
import results from '../.jest-test-results.json';
import { withTests } from '@storybook/addon-jest';
export default {

@@ -141,5 +138,3 @@ component: MyComponent,

// .storybook/preview.js
import { withTests } from '@storybook/addon-jest';
import results from '../.jest-test-results.json';

@@ -186,3 +181,2 @@

// MyComponent.stories.js|jsx
import MyComponent from './MyComponent';

@@ -215,5 +209,3 @@

// .storybook/preview.js
import { withTests } from '@storybook/addon-jest';
import results from '../.jest-test-results.json';

@@ -233,5 +225,3 @@

// MyComponent.stories.ts
import type { Meta, StoryFn } from '@storybook/angular';
import MyComponent from './MyComponent.component';

@@ -238,0 +228,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc