storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/uploads/__tests__/UploadModal.test.js (about) 1 /* 2 * MinIO Cloud Storage (C) 2018 MinIO, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 import React from "react" 18 import { shallow } from "enzyme" 19 import { UploadModal } from "../UploadModal" 20 21 describe("UploadModal", () => { 22 it("should render without crashing", () => { 23 shallow(<UploadModal uploads={{}} />) 24 }) 25 26 it("should render AbortConfirmModal when showAbort is true", () => { 27 const wrapper = shallow(<UploadModal uploads={{}} showAbort={true} />) 28 expect(wrapper.find("Connect(AbortConfirmModal)").length).toBe(1) 29 }) 30 31 it("should render nothing when there are no files being uploaded", () => { 32 const wrapper = shallow(<UploadModal uploads={{}} />) 33 expect(wrapper.find("noscript").length).toBe(1) 34 }) 35 36 it("should show upload progress when one or more files are being uploaded", () => { 37 const wrapper = shallow( 38 <UploadModal 39 uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }} 40 /> 41 ) 42 expect(wrapper.find("ProgressBar").length).toBe(1) 43 }) 44 45 it("should call showAbortModal when close button is clicked", () => { 46 const showAbortModal = jest.fn() 47 const wrapper = shallow( 48 <UploadModal 49 uploads={{ "a-b/-test": { size: 100, loaded: 50, name: "test" } }} 50 showAbortModal={showAbortModal} 51 /> 52 ) 53 wrapper.find("button").simulate("click") 54 expect(showAbortModal).toHaveBeenCalled() 55 }) 56 })