Liferay.Loader.define("@liferay/analytics-settings-web@5.0.51/js/utils/__tests__/request.spec",["module","exports","require","liferay!analytics-settings-web$jest-fetch-mock","frontend-js-web","../request"],(function(e,t,s){window;{s("liferay!analytics-settings-web$jest-fetch-mock");var n=s("frontend-js-web"),o=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(s("../request"));jest.mock("frontend-js-web",(()=>({fetch:jest.fn()})));const e=window.location;beforeAll((()=>{Object.defineProperty(window,"location",{configurable:!0,value:{reload:jest.fn()}})})),afterAll((()=>{Object.defineProperty(window,"location",{configurable:!0,value:e})})),describe("request",(()=>{beforeEach((()=>{jest.clearAllMocks()})),it("return OK when response status is 204",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:204,statusText:"NoContent"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({ok:!0})})),it("return error when response status is 400",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:400,statusText:"BadRequest"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({error:new Error("Request Error")})})),it("return error when response status is 401",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:401,statusText:"Unauthorized"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({error:new Error("Unauthorized Access")})})),it("return error when response status is 403",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:403,statusText:"Forbidden"}));const e=await(0,o.default)("/test",{});expect(e).toEqual(new Response(null,{headers:{"Content-Type":"application/json"},status:403,statusText:"Forbidden"})),expect(jest.isMockFunction(window.location.reload)).toBe(!0)})),it("return error when response status is 500",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:500,statusText:"InternalServerError"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({error:new Error("Request Error")})})),it("return error when response status is 404",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:404,statusText:"NotFound"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({error:new Error("Request Error")})})),it("return error when response status is 300",(async()=>{n.fetch.mockResolvedValue(new Response(null,{headers:{"Content-Type":"application/json"},status:300,statusText:"MultipleChoices"}));const e=await(0,o.default)("/test",{});expect(e).toEqual({error:new Error("Request Error")})}))}))}}));
//# sourceMappingURL=request.spec.js.map