Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/components/people/__tests__/OrganizationsModal.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!frontend-js-react-web$react","liferay!frontend-js-react-web$react-dom","../Modal","../People"],(function(e,t,a){window;{var n=_interopRequireDefault(a("liferay!analytics-settings-web$jest-fetch-mock"));a("@liferay!analytics-settings-web$testing-library/jest-dom/extend-expect");var s=a("@frontend-taglib-clay$clayui/modal"),i=a("@liferay!analytics-settings-web$testing-library/react"),r=_interopRequireDefault(a("liferay!frontend-js-react-web$react")),o=_interopRequireDefault(a("liferay!frontend-js-react-web$react-dom")),l=_interopRequireDefault(a("../Modal")),c=a("../People");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={actions:{},facets:[],items:[{id:44536,name:"organizations test",selected:!1},{id:44542,name:"organizations test 2",selected:!1}],lastPage:1,page:1,pageSize:20,totalCount:2},t={actions:{},facets:[],items:[{id:44536,name:"organizations test",selected:!0},{id:44542,name:"organizations test 2",selected:!0}],lastPage:1,page:1,pageSize:20,totalCount:2},d={actions:{},facets:[],items:[],lastPage:1,page:1,pageSize:20,totalCount:0},ComponentWithData=({requestFn:e})=>{const{observer:t}=(0,s.useModal)({onClose:()=>{}});return r.default.createElement(l.default,{columns:[{expanded:!0,id:"name",label:Liferay.Language.get("organizations")}],emptyState:{contentRenderer:()=>r.default.createElement(r.default.Fragment,null),description:"Empty State Description",noResultsTitle:"Empty State No Results Title",title:"Empty State Title"},name:c.EPeople.OrganizationIds,observer:t,onCloseModal:()=>{},requestFn:e,syncAllAccounts:!0,syncAllContacts:!0,syncedIds:{syncedAccountGroupIds:[""],syncedOrganizationIds:[""],syncedUserGroupIds:[""]},title:"Assign Modal Title"})},ComponentWithEmptyState=({requestFn:e})=>{const{observer:t}=(0,s.useModal)({onClose:()=>{}});return r.default.createElement(l.default,{columns:[],emptyState:{contentRenderer:()=>r.default.createElement(r.default.Fragment,null),description:"Empty State Description",noResultsTitle:"Empty State No Results Title",title:"There are no organizations"},name:c.EPeople.OrganizationIds,observer:t,onCloseModal:()=>{},requestFn:e,syncAllAccounts:!0,syncAllContacts:!0,syncedIds:{syncedAccountGroupIds:[""],syncedOrganizationIds:[""],syncedUserGroupIds:[""]},title:"Add Organizations"})};describe("Organizations Modal",(()=>{beforeAll((()=>{o.default.createPortal=jest.fn((e=>e)),jest.useFakeTimers()})),afterAll((()=>{jest.useRealTimers()})),afterEach((()=>{jest.clearAllTimers(),jest.restoreAllMocks(),(0,i.cleanup)()})),it("renders Organizations Modal with data without crashing it",(async()=>{n.default.mockResponse(JSON.stringify(e)),await(0,i.act)((async()=>{(0,i.render)(r.default.createElement(ComponentWithData,{requestFn:async()=>e})),jest.runAllTimers(),await(0,i.waitFor)((()=>i.screen.getByText("organizations test"))),await(0,i.waitFor)((()=>i.screen.getByText("organizations test 2")))}));const t=document.querySelector(".modal-content"),a=i.screen.getByText("organizations test"),s=i.screen.getByText("organizations test 2");expect(t).toBeInTheDocument(),expect(a).toBeInTheDocument(),expect(s).toBeInTheDocument()})),it("renders Organizations Modal with Empty State without crashing it",(async()=>{n.default.mockResponse(JSON.stringify(d)),await(0,i.act)((async()=>{(0,i.render)(r.default.createElement(ComponentWithEmptyState,{requestFn:async()=>d})),jest.runAllTimers()}));const e=i.screen.getByText("Add Organizations"),t=i.screen.getByText("There are no organizations"),a=i.screen.getByText("Empty State Description");expect(e).toBeInTheDocument(),expect(t).toBeInTheDocument(),expect(a).toBeInTheDocument()})),it.skip("renders Organizations Modal, click on checkbox to select all items",(async()=>{n.default.mockResponse(JSON.stringify(e)),await(0,i.act)((async()=>{(0,i.render)(r.default.createElement(ComponentWithData,{requestFn:async()=>e})),jest.runAllTimers()}));const a=i.screen.getByRole("navigation"),s=(0,i.within)(a).getByRole("checkbox");await(0,i.act)((async()=>{i.fireEvent.click(s)})),n.default.mockResponse(JSON.stringify(t));const o=document.querySelector('tr[data-testid="organizations test"]'),l=document.querySelector('tr[data-testid="organizations test 2"]');expect(o).toHaveClass("table-active"),expect(l).toHaveClass("table-active")}))}))}}));
//# sourceMappingURL=OrganizationsModal.spec.js.map