Fix failing unit tests in browser (#5688)

* format js files using prettier

Used the following command to format the files
prettier --write "browser/app/js/**/*.js"

* fix failing unit tests in browser
This commit is contained in:
Kanagaraj M
2018-03-23 00:55:56 +05:30
committed by Harshavardhana
parent cb3818be27
commit c0e45f9098
95 changed files with 839 additions and 890 deletions

View File

@@ -24,12 +24,12 @@ jest.mock("../../web", () => ({
return Promise.resolve({
buckets: [
{
name: "test1",
name: "test1"
},
{
name: "test2",
},
],
name: "test2"
}
]
})
}),
MakeBucket: jest.fn(() => {
@@ -37,11 +37,11 @@ jest.mock("../../web", () => ({
}),
DeleteBucket: jest.fn(() => {
return Promise.resolve()
}),
})
}))
jest.mock("../../objects/actions", () => ({
selectPrefix: () => dispatch => {},
selectPrefix: () => dispatch => {}
}))
const middlewares = [thunk]
@@ -53,12 +53,12 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SET_LIST",
buckets: ["test1", "test2"],
buckets: ["test1", "test2"]
},
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test1",
},
bucket: "test1"
}
]
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
const actions = store.getActions()
@@ -72,12 +72,12 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SET_LIST",
buckets: ["test1", "test2"],
buckets: ["test1", "test2"]
},
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test2",
},
bucket: "test2"
}
]
window.location
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
@@ -92,12 +92,12 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SET_LIST",
buckets: ["test1", "test2"],
buckets: ["test1", "test2"]
},
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test1",
},
bucket: "test1"
}
]
window.location
return store.dispatch(actionsBuckets.fetchBuckets()).then(() => {
@@ -111,8 +111,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test1",
},
bucket: "test1"
}
]
store.dispatch(actionsBuckets.selectBucket("test1"))
const actions = store.getActions()
@@ -124,8 +124,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
show: true,
},
show: true
}
]
store.dispatch(actionsBuckets.showMakeBucketModal())
const actions = store.getActions()
@@ -137,8 +137,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SHOW_MAKE_BUCKET_MODAL",
show: false,
},
show: false
}
]
store.dispatch(actionsBuckets.hideMakeBucketModal())
const actions = store.getActions()
@@ -150,8 +150,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SHOW_BUCKET_POLICY",
show: true,
},
show: true
}
]
store.dispatch(actionsBuckets.showBucketPolicy())
const actions = store.getActions()
@@ -163,8 +163,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SHOW_BUCKET_POLICY",
show: false,
},
show: false
}
]
store.dispatch(actionsBuckets.hideBucketPolicy())
const actions = store.getActions()
@@ -176,8 +176,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/SET_POLICIES",
policies: ["test1", "test2"],
},
policies: ["test1", "test2"]
}
]
store.dispatch(actionsBuckets.setPolicies(["test1", "test2"]))
const actions = store.getActions()
@@ -189,8 +189,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/ADD",
bucket: "test",
},
bucket: "test"
}
]
store.dispatch(actionsBuckets.addBucket("test"))
const actions = store.getActions()
@@ -202,8 +202,8 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/REMOVE",
bucket: "test",
},
bucket: "test"
}
]
store.dispatch(actionsBuckets.removeBucket("test"))
const actions = store.getActions()
@@ -215,12 +215,12 @@ describe("Buckets actions", () => {
const expectedActions = [
{
type: "buckets/ADD",
bucket: "test1",
bucket: "test1"
},
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test1",
},
bucket: "test1"
}
]
return store.dispatch(actionsBuckets.makeBucket("test1")).then(() => {
const actions = store.getActions()
@@ -239,26 +239,26 @@ describe("Buckets actions", () => {
alert: {
id: 0,
message: "Bucket 'test3' has been deleted.",
type: "info",
},
type: "info"
}
},
{
type: "buckets/REMOVE",
bucket: "test3",
bucket: "test3"
},
{
type: "buckets/SET_LIST",
buckets: ["test1", "test2"],
buckets: ["test1", "test2"]
},
{
type: "buckets/SET_CURRENT_BUCKET",
bucket: "test1",
},
bucket: "test1"
}
]
return store.dispatch(actionsBuckets.deleteBucket("test3")).then(() => {
const actions = store.getActions()
expect(actions).toEqual(expectedActions)
})
},
}
)
})