@figlinq/react-chart-editor
Version:
plotly.js chart editor react component UI
2 lines • 8.89 kB
JavaScript
function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==typeof i?i:i+""}function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}import{Numeric,Info}from"../../fields";import{Panel,Fold,Section,LayoutPanel,PlotlySection}from"..";import{TestEditor,fixtures,mount}from"../../../lib/test-utils";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";describe("Basic Panel rules",()=>{describe("not connected, provides no context, cannot use with Fields",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsxs(Panel,{children:[_jsx("div",{id:"thediv",children:" ok "}),_jsx(Numeric,{attr:"title"})]})})));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0));it("SHOWS div which does not need context",()=>expect(wrapper.find("input").length).toEqual(0))});describe("displays all it's children",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsxs(Panel,{children:[_jsxs(Section,{children:[_jsx("div",{id:"thediv",children:" ok "}),_jsx(Numeric,{attr:"title"})]}),_jsx(Fold,{children:_jsx("div",{id:"theseconddiv"})}),_jsx(Fold,{children:_jsx(Info,{})})]})})));it("SHOWS Section, Fold, #thediv, #theseconddiv, Info",()=>{expect(wrapper.find("div.section").length).toEqual(1);expect(wrapper.find("div.fold").length).toEqual(2);expect(wrapper.find("#thediv").length).toEqual(1);expect(wrapper.find("#theseconddiv").length).toEqual(1);expect(wrapper.find(".js-test-info").length).toEqual(1)});it("HIDES Field because it needs context",()=>expect(wrapper.find("input").length).toEqual(0));it("PANEL shows collapse functionality, FOLD is foldable",()=>{expect(wrapper.find(".panel__header__collapse").length).toEqual(1);expect(wrapper.find(Fold).first().props().folded).toBe(false);expect(typeof wrapper.find(Fold).first().props().toggleFold).toBe("function")})})});describe("Basic Section rules",()=>{describe("always shows itself and its children",()=>{describe("Panel > Section > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(Panel,{children:_jsx(Section,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS Section because it always shows itself",()=>expect(wrapper.find("div.section").length).toEqual(1));it("HIDES Field because there's no context for it",()=>expect(wrapper.find("input").length).toEqual(0))});describe("PlotlyPanel > Section > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Section,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS Section because it always shows itself",()=>expect(wrapper.find("div.section").length).toEqual(1));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("PlotlyPanel > Section > Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Section,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})));it("SHOWS Section because it always shows itself",()=>expect(wrapper.find("div.section").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("Panel > Section > div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(Panel,{children:_jsx(Section,{children:_jsx("div",{id:"thediv"})})})})));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("SHOWS div",()=>expect(wrapper.find("#thediv").length).toEqual(1))})})});describe("Basic Fold rules",()=>{describe("always shows itself and its children",()=>{describe("Panel > Fold > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(Panel,{children:_jsx(Fold,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("HIDES Field because it has no context",()=>expect(wrapper.find("input").length).toEqual(0))});describe("LayoutPanel > Fold > Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(Numeric,{attr:"title"})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("LayoutPanel > Fold > Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))});describe("Panel > Fold > div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(Panel,{children:_jsx(Fold,{children:_jsx("div",{id:"thediv",children:" ok "})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS div",()=>expect(wrapper.find("#thediv").length).toEqual(1))});describe("no_visibility_forcing, plotly_editor_trait have no effect",()=>{describe("PlotlySection",()=>{describe("div",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(Panel,{children:_jsx(Fold,{children:_jsx(PlotlySection,{children:_jsx("div",{id:"thediv",children:" ok "})})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("SHOWS div",()=>expect(wrapper.find("#thediv").length).toEqual(1))});describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"title"})})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS PlotlySection",()=>expect(wrapper.find("div.section").length).toEqual(1));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))});describe("Field-with-invisible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(PlotlySection,{children:_jsx(Numeric,{attr:"not_an_attr"})})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("HIDES PlotlySection because Plotly Section visibility rules apply",()=>expect(wrapper.find("div.section").length).toEqual(0));it("HIDES Field",()=>expect(wrapper.find("input").length).toEqual(0))})})});describe("PlotlyPanel",()=>{describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(LayoutPanel,{children:_jsx(Numeric,{attr:"title"})})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS PlotlyPanel",()=>expect(wrapper.find("div.panel").length).toEqual(2));it("SHOWS Field",()=>expect(wrapper.find("input").length).toEqual(1))})});describe("Info",()=>{describe("Field-with-visible-attr",()=>{const wrapper=mount(_jsx(TestEditor,_objectSpread(_objectSpread({},fixtures.scatter()),{},{children:_jsx(LayoutPanel,{children:_jsx(Fold,{children:_jsx(Info,{children:"ok"})})})})));it("SHOWS Fold",()=>expect(wrapper.find("div.fold").length).toEqual(1));it("SHOWS Info",()=>expect(wrapper.find(".js-test-info").length).toEqual(1))})})})});
//# sourceMappingURL=UnconnectedContainersVisibility-test.js.map