Browser: Update UI with new components and elements (#5671)

This commit is contained in:
Rushan
2018-03-21 23:39:23 +05:30
committed by Harshavardhana
parent 384b4fdf28
commit 1459c4be1e
199 changed files with 10549 additions and 4702 deletions

View File

@@ -31,20 +31,34 @@ describe("objects reducer", () => {
shareObject: {
show: false,
object: "",
url: ""
url: "",
},
checkedList: []
checkedList: [],
})
})
it("should handle SET_LIST", () => {
const newState = reducer(undefined, {
type: actions.SET_LIST,
objects: [{ name: "obj1" }, { name: "obj2" }],
objects: [
{
name: "obj1",
},
{
name: "obj2",
},
],
marker: "obj2",
isTruncated: false
isTruncated: false,
})
expect(newState.list).toEqual([{ name: "obj1" }, { name: "obj2" }])
expect(newState.list).toEqual([
{
name: "obj1",
},
{
name: "obj2",
},
])
expect(newState.marker).toBe("obj2")
expect(newState.isTruncated).toBeFalsy()
})
@@ -52,22 +66,44 @@ describe("objects reducer", () => {
it("should handle APPEND_LIST", () => {
const newState = reducer(
{
list: [{ name: "obj1" }, { name: "obj2" }],
list: [
{
name: "obj1",
},
{
name: "obj2",
},
],
marker: "obj2",
isTruncated: true
isTruncated: true,
},
{
type: actions.APPEND_LIST,
objects: [{ name: "obj3" }, { name: "obj4" }],
objects: [
{
name: "obj3",
},
{
name: "obj4",
},
],
marker: "obj4",
isTruncated: false
}
isTruncated: false,
},
)
expect(newState.list).toEqual([
{ name: "obj1" },
{ name: "obj2" },
{ name: "obj3" },
{ name: "obj4" }
{
name: "obj1",
},
{
name: "obj2",
},
{
name: "obj3",
},
{
name: "obj4",
},
])
expect(newState.marker).toBe("obj4")
expect(newState.isTruncated).toBeFalsy()
@@ -75,30 +111,59 @@ describe("objects reducer", () => {
it("should handle REMOVE", () => {
const newState = reducer(
{ list: [{ name: "obj1" }, { name: "obj2" }] },
{
list: [
{
name: "obj1",
},
{
name: "obj2",
},
],
},
{
type: actions.REMOVE,
object: "obj1"
}
object: "obj1",
},
)
expect(newState.list).toEqual([{ name: "obj2" }])
expect(newState.list).toEqual([
{
name: "obj2",
},
])
})
it("should handle REMOVE with non-existent object", () => {
const newState = reducer(
{ list: [{ name: "obj1" }, { name: "obj2" }] },
{
list: [
{
name: "obj1",
},
{
name: "obj2",
},
],
},
{
type: actions.REMOVE,
object: "obj3"
}
object: "obj3",
},
)
expect(newState.list).toEqual([{ name: "obj1" }, { name: "obj2" }])
expect(newState.list).toEqual([
{
name: "obj1",
},
{
name: "obj2",
},
])
})
it("should handle SET_SORT_BY", () => {
const newState = reducer(undefined, {
type: actions.SET_SORT_BY,
sortBy: "name"
sortBy: "name",
})
expect(newState.sortBy).toEqual("name")
})
@@ -106,18 +171,22 @@ describe("objects reducer", () => {
it("should handle SET_SORT_ORDER", () => {
const newState = reducer(undefined, {
type: actions.SET_SORT_ORDER,
sortOrder: true
sortOrder: true,
})
expect(newState.sortOrder).toEqual(true)
})
it("should handle SET_CURRENT_PREFIX", () => {
const newState = reducer(
{ currentPrefix: "test1/", marker: "abc", isTruncated: true },
{
currentPrefix: "test1/",
marker: "abc",
isTruncated: true,
},
{
type: actions.SET_CURRENT_PREFIX,
prefix: "test2/"
}
prefix: "test2/",
},
)
expect(newState.currentPrefix).toEqual("test2/")
expect(newState.marker).toEqual("")
@@ -127,7 +196,7 @@ describe("objects reducer", () => {
it("should handle SET_PREFIX_WRITABLE", () => {
const newState = reducer(undefined, {
type: actions.SET_PREFIX_WRITABLE,
prefixWritable: true
prefixWritable: true,
})
expect(newState.prefixWritable).toBeTruthy()
})
@@ -137,40 +206,44 @@ describe("objects reducer", () => {
type: actions.SET_SHARE_OBJECT,
show: true,
object: "a.txt",
url: "test"
url: "test",
})
expect(newState.shareObject).toEqual({
show: true,
object: "a.txt",
url: "test"
url: "test",
})
})
it("should handle CHECKED_LIST_ADD", () => {
const newState = reducer(undefined, {
type: actions.CHECKED_LIST_ADD,
object: "obj1"
object: "obj1",
})
expect(newState.checkedList).toEqual(["obj1"])
})
it("should handle SELECTED_LIST_REMOVE", () => {
const newState = reducer(
{ checkedList: ["obj1", "obj2"] },
{
checkedList: ["obj1", "obj2"],
},
{
type: actions.CHECKED_LIST_REMOVE,
object: "obj1"
}
object: "obj1",
},
)
expect(newState.checkedList).toEqual(["obj2"])
})
it("should handle CHECKED_LIST_RESET", () => {
const newState = reducer(
{ checkedList: ["obj1", "obj2"] },
{
type: actions.CHECKED_LIST_RESET
}
checkedList: ["obj1", "obj2"],
},
{
type: actions.CHECKED_LIST_RESET,
},
)
expect(newState.checkedList).toEqual([])
})