1/*! For license information please see ImagePicker-components-ImagePickerPreview-__tests__-ImagePickerPreview-test.a1d7fb6.js.LICENSE.txt */ 2"use strict";(self.webpackChunkcookiefirst_admin_panel=self.webpackChunkcookiefirst_admin_panel||[]).push([[5358],{57679:function(e,t,n){n.r(t);var o=n(58168),r=n(40253),c=n(96540),l=n(4305);jest.mock("../../../../../../Icon",function(){return function(e){var t=e.icon;return c.createElement("span",{"data-testid":"icon-".concat(t)})}}),describe("ImagePickerPreview",function(){var e={src:"https://example.com/image.jpg",onEdit:jest.fn(),onDelete:jest.fn()};beforeEach(function(){jest.clearAllMocks()}),it("should render preview container",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container;expect(t.querySelector(".previewContainer")).toBeInTheDocument()}),it("should render default preview",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container;expect(t.querySelector(".preview")).toBeInTheDocument()}),it("should apply background image to preview",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container.querySelector(".preview");expect(t).toHaveStyle({backgroundImage:"url('https://example.com/image.jpg')"})}),it("should render actions container",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container;expect(t.querySelector(".actions")).toBeInTheDocument()}),it("should render edit button when allowEdit is true",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!0}))).container;expect(t.querySelector(".editBtn")).toBeInTheDocument()}),it("should not render edit button when allowEdit is false",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!1}))).container;expect(t.querySelector(".editBtn")).not.toBeInTheDocument()}),it("should render delete button when allowDelete is true",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowDelete:!0}))).container;expect(t.querySelector(".deleteBtn")).toBeInTheDocument()}),it("should not render delete button when allowDelete is false",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowDelete:!1}))).container;expect(t.querySelector(".deleteBtn")).not.toBeInTheDocument()}),it("should render edit icon",function(){(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!0}))),expect(r.nj.getByTestId("icon-md/ic_mode_edit")).toBeInTheDocument()}),it("should render delete icon",function(){(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowDelete:!0}))),expect(r.nj.getByTestId("icon-md/ic_delete")).toBeInTheDocument()}),it("should call onEdit when edit button clicked",function(){var t=jest.fn(),n=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!0,onEdit:t}))).container.querySelector(".editBtn");r.rC.click(n),expect(t).toHaveBeenCalled()}),it("should call onDelete when delete button clicked",function(){var t=jest.fn(),n=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowDelete:!0,onDelete:t}))).container.querySelector(".deleteBtn");r.rC.click(n),expect(t).toHaveBeenCalled()}),it("should apply custom className",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{className:"custom-class"}))).container;expect(t.querySelector(".previewContainer")).toHaveClass("custom-class")}),it("should apply empty class when no src",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{src:""}))).container;expect(t.querySelector(".previewContainer")).toHaveClass("empty")}),it("should not apply empty class when src provided",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container;expect(t.querySelector(".previewContainer")).not.toHaveClass("empty")}),it("should apply empty class to preview when no src",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{src:""}))).container;expect(t.querySelector(".preview")).toHaveClass("empty")}),it("should have button type for edit button",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!0}))).container.querySelector(".editBtn");expect(t).toHaveAttribute("type","button")}),it("should have button type for delete button",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowDelete:!0}))).container.querySelector(".deleteBtn");expect(t).toHaveAttribute("type","button")}),it("should render custom preview when renderPreview provided",function(){(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{renderPreview:function(e){var t=e.src;return c.createElement("div",{"data-testid":"custom-preview"},"Custom: ",t)}}))),expect(r.nj.getByTestId("custom-preview")).toBeInTheDocument(),expect(r.nj.getByTestId("custom-preview")).toHaveTextContent("Custom: https://example.com/image.jpg")}),it("should pass src to custom renderPreview",function(){var t=jest.fn(function(){return c.createElement("div",null,"Custom")});(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{src:"https://test.com/pic.png",renderPreview:t}))),expect(t).toHaveBeenCalledWith({src:"https://test.com/pic.png"})}),it("should render both edit and delete buttons",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{allowEdit:!0,allowDelete:!0}))).container;expect(t.querySelector(".editBtn")).toBeInTheDocument(),expect(t.querySelector(".deleteBtn")).toBeInTheDocument()}),it("should not render action buttons by default",function(){var t=(0,r.XX)(c.createElement(l.default,e)).container;expect(t.querySelector(".editBtn")).not.toBeInTheDocument(),expect(t.querySelector(".deleteBtn")).not.toBeInTheDocument()}),it("should handle empty src string",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{src:""}))).container.querySelector(".preview");expect(t).toHaveStyle({backgroundImage:"url('')"})}),it("should handle different image URLs",function(){var t=(0,r.XX)(c.createElement(l.default,(0,o.A)({},e,{src:"https://different.com/photo.png"}))).container.querySelector(".preview");expect(t).toHaveStyle({backgroundImage:"url('https://different.com/photo.png')"})})})}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.