mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
Browser: Update UI with new components and elements (#5671)
This commit is contained in:
@@ -20,13 +20,13 @@ import { ShareObjectModal } from "../ShareObjectModal"
|
||||
import {
|
||||
SHARE_OBJECT_EXPIRY_DAYS,
|
||||
SHARE_OBJECT_EXPIRY_HOURS,
|
||||
SHARE_OBJECT_EXPIRY_MINUTES
|
||||
SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
} from "../../constants"
|
||||
|
||||
jest.mock("../../web", () => ({
|
||||
LoggedIn: jest.fn(() => {
|
||||
return true
|
||||
})
|
||||
}),
|
||||
}))
|
||||
|
||||
describe("ShareObjectModal", () => {
|
||||
@@ -35,7 +35,7 @@ describe("ShareObjectModal", () => {
|
||||
<ShareObjectModal
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
/>
|
||||
/>,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -46,7 +46,7 @@ describe("ShareObjectModal", () => {
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
hideShareObject={hideShareObject}
|
||||
/>
|
||||
/>,
|
||||
)
|
||||
wrapper
|
||||
.find("button")
|
||||
@@ -60,13 +60,13 @@ describe("ShareObjectModal", () => {
|
||||
<ShareObjectModal
|
||||
object={{ name: "obj1" }}
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
/>
|
||||
/>,
|
||||
)
|
||||
expect(
|
||||
wrapper
|
||||
.find("input")
|
||||
.first()
|
||||
.prop("value")
|
||||
.prop("value"),
|
||||
).toBe(`${window.location.protocol}//test`)
|
||||
})
|
||||
|
||||
@@ -79,7 +79,7 @@ describe("ShareObjectModal", () => {
|
||||
shareObjectDetails={{ show: true, object: "obj1", url: "test" }}
|
||||
hideShareObject={hideShareObject}
|
||||
showCopyAlert={showCopyAlert}
|
||||
/>
|
||||
/>,
|
||||
)
|
||||
wrapper.find("CopyToClipboard").prop("onCopy")()
|
||||
expect(showCopyAlert).toHaveBeenCalledWith("Link copied to clipboard!")
|
||||
@@ -88,35 +88,41 @@ describe("ShareObjectModal", () => {
|
||||
|
||||
describe("Update expiry values", () => {
|
||||
const props = {
|
||||
object: { name: "obj1" },
|
||||
shareObjectDetails: { show: true, object: "obj1", url: "test" }
|
||||
object: {
|
||||
name: "obj1",
|
||||
},
|
||||
shareObjectDetails: {
|
||||
show: true,
|
||||
object: "obj1",
|
||||
url: "test",
|
||||
},
|
||||
}
|
||||
it("should have default expiry values", () => {
|
||||
const wrapper = shallow(<ShareObjectModal {...props} />)
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: SHARE_OBJECT_EXPIRY_DAYS,
|
||||
hours: SHARE_OBJECT_EXPIRY_HOURS,
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES
|
||||
minutes: SHARE_OBJECT_EXPIRY_MINUTES,
|
||||
})
|
||||
})
|
||||
|
||||
it("should not allow any increments when days is already max", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
}
|
||||
minutes: 0,
|
||||
},
|
||||
})
|
||||
wrapper.find("#increase-hours").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
minutes: 0,
|
||||
})
|
||||
expect(shareObject).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -124,14 +130,14 @@ describe("ShareObjectModal", () => {
|
||||
it("should not allow expiry values less than minimum value", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 5,
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
}
|
||||
minutes: 0,
|
||||
},
|
||||
})
|
||||
wrapper.find("#decrease-hours").simulate("click")
|
||||
expect(wrapper.state("expiry").hours).toBe(0)
|
||||
@@ -143,14 +149,14 @@ describe("ShareObjectModal", () => {
|
||||
it("should not allow expiry values more than maximum value", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 1,
|
||||
hours: 23,
|
||||
minutes: 59
|
||||
}
|
||||
minutes: 59,
|
||||
},
|
||||
})
|
||||
wrapper.find("#increase-hours").simulate("click")
|
||||
expect(wrapper.state("expiry").hours).toBe(23)
|
||||
@@ -162,20 +168,20 @@ describe("ShareObjectModal", () => {
|
||||
it("should set hours and minutes to 0 when days reaches max", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 6,
|
||||
hours: 5,
|
||||
minutes: 30
|
||||
}
|
||||
minutes: 30,
|
||||
},
|
||||
})
|
||||
wrapper.find("#increase-days").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
minutes: 0,
|
||||
})
|
||||
expect(shareObject).toHaveBeenCalled()
|
||||
})
|
||||
@@ -183,20 +189,20 @@ describe("ShareObjectModal", () => {
|
||||
it("should set days to MAX when all of them becomes 0", () => {
|
||||
const shareObject = jest.fn()
|
||||
const wrapper = shallow(
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />
|
||||
<ShareObjectModal {...props} shareObject={shareObject} />,
|
||||
)
|
||||
wrapper.setState({
|
||||
expiry: {
|
||||
days: 0,
|
||||
hours: 1,
|
||||
minutes: 0
|
||||
}
|
||||
minutes: 0,
|
||||
},
|
||||
})
|
||||
wrapper.find("#decrease-hours").simulate("click")
|
||||
expect(wrapper.state("expiry")).toEqual({
|
||||
days: 7,
|
||||
hours: 0,
|
||||
minutes: 0
|
||||
minutes: 0,
|
||||
})
|
||||
expect(shareObject).toHaveBeenCalledWith("obj1", 7, 0, 0)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user