storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/browser/app/js/uploads/__tests__/AbortConfirmModal.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 { AbortConfirmModal } from "../AbortConfirmModal"
    20  
    21  describe("AbortConfirmModal", () => {
    22    it("should render without crashing", () => {
    23      shallow(<AbortConfirmModal />)
    24    })
    25  
    26    it("should call abort for every upload when Abort is clicked", () => {
    27      const abort = jest.fn()
    28      const wrapper = shallow(
    29        <AbortConfirmModal
    30          uploads={{
    31            "a-b/-test1": { size: 100, loaded: 50, name: "test1" },
    32            "a-b/-test2": { size: 100, loaded: 50, name: "test2" }
    33          }}
    34          abort={abort}
    35        />
    36      )
    37      wrapper.instance().abortUploads()
    38      expect(abort.mock.calls.length).toBe(2)
    39      expect(abort.mock.calls[0][0]).toBe("a-b/-test1")
    40      expect(abort.mock.calls[1][0]).toBe("a-b/-test2")
    41    })
    42  
    43    it("should call hideAbort when cancel is clicked", () => {
    44      const hideAbort = jest.fn()
    45      const wrapper = shallow(<AbortConfirmModal hideAbort={hideAbort} />)
    46      wrapper.find("ConfirmModal").prop("cancelHandler")()
    47      expect(hideAbort).toHaveBeenCalled()
    48    })
    49  })