mirror of
https://github.com/minio/minio.git
synced 2024-12-29 08:33:21 -05:00
a6adef0bdf
This commit adds the bucket delete and bucket policy functionalities to the browser. Part of rewriting the browser code to follow best practices and guidelines of React (issues #5409 and #5410) The backend code has been modified by @krishnasrinivas to prevent issue #4498 from occuring. The relevant changes have been made to the code according to the latest commit and the unit tests in the backend. This commit also addresses issue #5449.
64 lines
1.9 KiB
JavaScript
64 lines
1.9 KiB
JavaScript
/*
|
|
* Minio Cloud Storage (C) 2018 Minio, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
import React from "react"
|
|
import { shallow, mount } from "enzyme"
|
|
import { Policy } from "../Policy"
|
|
import { READ_ONLY, WRITE_ONLY, READ_WRITE } from "../../constants"
|
|
import web from "../../web"
|
|
|
|
jest.mock("../../web", () => ({
|
|
SetBucketPolicy: jest.fn(() => {
|
|
return Promise.resolve()
|
|
})
|
|
}))
|
|
|
|
describe("Policy", () => {
|
|
it("should render without crashing", () => {
|
|
shallow(<Policy currentBucket={"bucket"} prefix={"foo"} policy={READ_ONLY} />)
|
|
})
|
|
|
|
it("should call web.setBucketPolicy and fetchPolicies on submit", () => {
|
|
const fetchPolicies = jest.fn()
|
|
const wrapper = shallow(
|
|
<Policy
|
|
currentBucket={"bucket"}
|
|
prefix={"foo"}
|
|
policy={READ_ONLY}
|
|
fetchPolicies={fetchPolicies}
|
|
/>
|
|
)
|
|
wrapper.find("button").simulate("click", { preventDefault: jest.fn() })
|
|
|
|
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
|
|
bucketName: "bucket",
|
|
prefix: "foo",
|
|
policy: "none"
|
|
})
|
|
|
|
setImmediate(() => {
|
|
expect(fetchPolicies).toHaveBeenCalledWith("bucket")
|
|
})
|
|
})
|
|
|
|
it("should change the empty string to '*' while displaying prefixes", () => {
|
|
const wrapper = shallow(
|
|
<Policy currentBucket={"bucket"} prefix={""} policy={READ_ONLY} />
|
|
)
|
|
expect(wrapper.find(".pmbl-item").at(0).text()).toEqual("*")
|
|
})
|
|
})
|