Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/components/attributes/__tests__/Attributes.spec",["module","exports","require","liferay!analytics-settings-web$jest-fetch-mock","@liferay!analytics-settings-web$testing-library/jest-dom/extend-expect","@frontend-taglib-clay$clayui/modal","@liferay!analytics-settings-web$testing-library/react","@liferay!analytics-settings-web$testing-library/user-event","liferay!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dom","../Attributes","../Modal"],(function(e,t,n){window;{var r=_interopRequireDefault(n("liferay!analytics-settings-web$jest-fetch-mock"));n("@liferay!analytics-settings-web$testing-library/jest-dom/extend-expect");var a=n("@frontend-taglib-clay$clayui/modal"),c=n("@liferay!analytics-settings-web$testing-library/react"),s=_interopRequireDefault(n("@liferay!analytics-settings-web$testing-library/user-event")),o=_interopRequireDefault(n("liferay!frontend-js-react-web$react")),i=_interopRequireDefault(n("liferay!frontend-js-react-web$react-dom")),l=_interopRequireDefault(n("../Attributes")),u=_interopRequireDefault(n("../Modal"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={account:25,order:0,people:44,product:34},t={actions:{},facets:[],items:[{example:"True",name:"agreedToTermsOfUse",required:!1,selected:!0,source:"user",type:"Boolean"},{example:"31st Oct 2008",name:"birthday",required:!1,selected:!0,source:"contact",type:"Date"}]},ComponentWithData=({requestFn:e})=>{const{observer:t}=(0,a.useModal)({onClose:()=>{}});return o.default.createElement(u.default,{observer:t,onCancel:()=>{},onSubmit:()=>{},requestFn:e,title:"Assign Modal Title"})};describe("Attributes",(()=>{beforeAll((()=>{i.default.createPortal=jest.fn((e=>e)),jest.useFakeTimers()})),afterAll((()=>{jest.useRealTimers()})),afterEach((()=>{jest.clearAllTimers(),jest.restoreAllMocks(),(0,c.cleanup)()})),it("renders Attributes without crashing",(async()=>{r.default.mockResponseOnce(JSON.stringify(e)),await(0,c.act)((async()=>{(0,c.render)(o.default.createElement(l.default,null))})),expect(c.screen.getByText("people")).toBeInTheDocument(),expect(c.screen.getByText("account")).toBeInTheDocument(),expect(c.screen.getByText("products")).toBeInTheDocument(),expect(c.screen.getByText("order")).toBeInTheDocument()})),it("renders Attributes with values for account, order, people, product",(async()=>{r.default.mockResponseOnce(JSON.stringify(e)),(0,c.render)(o.default.createElement(l.default,null)),expect(await c.screen.findByRole(/people/i)).toHaveTextContent(/people44/i),expect(await c.screen.findByRole(/people/i)).toHaveTextContent(/selected/i),expect(await c.screen.findByRole(/account/i)).toHaveTextContent(/account25/i),expect(await c.screen.findByRole(/account/i)).toHaveTextContent(/selected/i),expect(await c.screen.findByRole(/product/i)).toHaveTextContent(/products34/i),expect(await c.screen.findByRole(/product/i)).toHaveTextContent(/selected/i),expect(await c.screen.findByRole(/order/i)).toHaveTextContent(/order0/i),expect(await c.screen.findByRole(/order/i)).toHaveTextContent(/selected/i)})),it("renders Attributes with select buttons",(async()=>{r.default.mockResponseOnce(JSON.stringify(e)),await(0,c.act)((async()=>{(0,c.render)(o.default.createElement(l.default,null))}));const t=c.screen.getAllByText("select-attributes");expect(t[0]).toBeInTheDocument(),expect(t[1]).toBeInTheDocument(),expect(t[2]).toBeInTheDocument(),expect(t[0]).toHaveAttribute("type","button"),expect(t[1]).toHaveAttribute("type","button"),expect(t[2]).toHaveAttribute("type","button")})),it.skip("renders Modal with data when select button is clicked",(async()=>{r.default.mockResponse(JSON.stringify(e)),(0,c.render)(o.default.createElement(l.default,null));const n=await c.screen.findAllByText("select-attributes"),a=document.getElementsByClassName("modal-content");s.default.click(n[0]),await(0,c.act)((async()=>{r.default.mockResponseOnce(JSON.stringify(t)),(0,c.render)(o.default.createElement(ComponentWithData,{requestFn:async()=>t})),jest.useFakeTimers(),await(0,c.waitFor)((()=>c.screen.getByText("agreedToTermsOfUse"))),await(0,c.waitFor)((()=>c.screen.getByText("birthday")))})),expect(a).toBeTruthy(),expect(c.screen.getByText("agreedToTermsOfUse")).toBeInTheDocument(),expect(c.screen.getByText("Boolean")).toBeInTheDocument(),expect(c.screen.getByText("True")).toBeInTheDocument(),expect(c.screen.getByText("user")).toBeInTheDocument(),expect(c.screen.getByText("birthday")).toBeInTheDocument(),expect(c.screen.getByText("Date")).toBeInTheDocument(),expect(c.screen.getByText("31st Oct 2008")).toBeInTheDocument(),expect(c.screen.getByText("contact")).toBeInTheDocument()}))}))}}));
//# sourceMappingURL=Attributes.spec.js.map