Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/components/properties/__tests__/CreatePropertyModal.spec",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/modal","@liferay!analytics-settings-web$testing-library/jest-dom/extend-expect","@liferay!analytics-settings-web$testing-library/react","liferay!frontend-js-react-web$classnames","liferay!frontend-js-react-web$react","../../../utils/constants"],(function(e,t,a){window;{var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/form")),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),c=_interopRequireDefault(a("@frontend-taglib-clay$clayui/modal"));a("@liferay!analytics-settings-web$testing-library/jest-dom/extend-expect");var i=a("@liferay!analytics-settings-web$testing-library/react"),o=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),u=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),s=a("../../../utils/constants");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const Component=({onCancel:e})=>{const[t,a]=(0,u.useState)(""),[i]=(0,u.useState)(!1),d=t.length>=s.MIN_LENGTH;return u.default.createElement(u.default.Fragment,null,u.default.createElement(r.default,{onSubmit:e=>e.preventDefault()},u.default.createElement(c.default.Header,null,Liferay.Language.get("new-property")),u.default.createElement(c.default.Body,{className:"pb-0 pt-3"},u.default.createElement(r.default.Group,{className:(0,o.default)({"has-error":t&&!d},"mb-3")},u.default.createElement("label",{htmlFor:"basicInputText"},Liferay.Language.get("property-name")),u.default.createElement(r.ClayInput,{id:"inputPropertyName",maxLength:s.MAX_LENGTH,onChange:({target:{value:e}})=>a(e),type:"text",value:t}),t&&!d&&u.default.createElement(r.default.FeedbackGroup,null,u.default.createElement(r.default.FeedbackItem,null,u.default.createElement(l.default,{className:"mr-1",symbol:"warning-full"}),u.default.createElement("span",null,Liferay.Language.get("property-name-does-not-meet-minimum-length-required")))))),u.default.createElement(c.default.Footer,{last:u.default.createElement(n.default.Group,{spaced:!0},u.default.createElement(n.default,{displayType:"secondary",onClick:e},Liferay.Language.get("cancel")),u.default.createElement(n.default,{disabled:!t||i||!d,onClick:()=>{}},Liferay.Language.get("create")))})))};describe("CreatePropertyModal",(()=>{it("renders component without crashing it",(()=>{(0,i.render)(u.default.createElement(Component,{onCancel:()=>{},onSubmit:()=>{}})),expect(i.screen.getByText(/new-property/i)).toBeInTheDocument(),expect(i.screen.getByText(/property-name/i)).toBeInTheDocument(),expect(i.screen.getByRole("button",{name:/cancel/i})).toBeInTheDocument(),expect(i.screen.getByRole("button",{name:/create/i})).toBeInTheDocument()})),it("renders component, writes a character in the input and checks if the minimum length message is displayed",(()=>{(0,i.render)(u.default.createElement(Component,{onCancel:()=>{},onSubmit:()=>{}})),expect(i.screen.getByText(/new-property/i)).toBeInTheDocument(),expect(i.screen.getByText(/property-name/i)).toBeInTheDocument();const e=i.screen.getByRole("textbox");expect(e).toBeInTheDocument(),expect(e).toHaveValue(""),i.fireEvent.change(e,{target:{value:"t"}}),expect(e).toHaveValue("t");const t=i.screen.getByRole("button",{name:/create/i});expect(t).toHaveAttribute("disabled"),expect(i.screen.getByText(/property-name-does-not-meet-minimum-length-required/i)).toBeInTheDocument()})),it("renders component, writes a character in the input and checks if the minimum length message is NOT displayed",(()=>{(0,i.render)(u.default.createElement(Component,{onCancel:()=>{},onSubmit:()=>{}})),expect(i.screen.getByText(/new-property/i)).toBeInTheDocument(),expect(i.screen.getByText(/property-name/i)).toBeInTheDocument();const e=i.screen.getByRole("textbox");expect(e).toBeInTheDocument(),expect(e).toHaveValue("");const t=i.screen.getByRole("button",{name:/create/i});expect(t).toHaveAttribute("disabled"),i.fireEvent.change(e,{target:{value:"test"}}),expect(e).toHaveValue("test"),expect(t).not.toHaveAttribute("disabled")}))}))}}));
//# sourceMappingURL=CreatePropertyModal.spec.js.map