Refactor delete object and share object components (#5537)

This commit is contained in:
Kanagaraj M
2018-02-19 09:37:59 +05:30
committed by Harshavardhana
parent 566ac78b8b
commit da4558a8f7
13 changed files with 988 additions and 6 deletions

View File

@@ -26,7 +26,12 @@ describe("objects reducer", () => {
sortOrder: false,
currentPrefix: "",
marker: "",
isTruncated: false
isTruncated: false,
shareObject: {
show: false,
object: "",
url: ""
}
})
})
@@ -66,6 +71,28 @@ describe("objects reducer", () => {
expect(newState.isTruncated).toBeFalsy()
})
it("should handle REMOVE", () => {
const newState = reducer(
{ list: [{ name: "obj1" }, { name: "obj2" }] },
{
type: actions.REMOVE,
object: "obj1"
}
)
expect(newState.list).toEqual([{ name: "obj2" }])
})
it("should handle REMOVE with non-existent object", () => {
const newState = reducer(
{ list: [{ name: "obj1" }, { name: "obj2" }] },
{
type: actions.REMOVE,
object: "obj3"
}
)
expect(newState.list).toEqual([{ name: "obj1" }, { name: "obj2" }])
})
it("should handle SET_SORT_BY", () => {
const newState = reducer(undefined, {
type: actions.SET_SORT_BY,
@@ -94,4 +121,18 @@ describe("objects reducer", () => {
expect(newState.marker).toEqual("")
expect(newState.isTruncated).toBeFalsy()
})
it("should handle SET_SHARE_OBJECT", () => {
const newState = reducer(undefined, {
type: actions.SET_SHARE_OBJECT,
show: true,
object: "a.txt",
url: "test"
})
expect(newState.shareObject).toEqual({
show: true,
object: "a.txt",
url: "test"
})
})
})