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

@@ -29,8 +29,8 @@ describe("Uploads actions", () => {
type: "uploads/ADD",
slug: "a-b-c",
size: 100,
name: "test",
},
name: "test"
}
]
store.dispatch(uploadsActions.add("a-b-c", 100, "test"))
const actions = store.getActions()
@@ -43,8 +43,8 @@ describe("Uploads actions", () => {
{
type: "uploads/UPDATE_PROGRESS",
slug: "a-b-c",
loaded: 50,
},
loaded: 50
}
]
store.dispatch(uploadsActions.updateProgress("a-b-c", 50))
const actions = store.getActions()
@@ -56,8 +56,8 @@ describe("Uploads actions", () => {
const expectedActions = [
{
type: "uploads/STOP",
slug: "a-b-c",
},
slug: "a-b-c"
}
]
store.dispatch(uploadsActions.stop("a-b-c"))
const actions = store.getActions()
@@ -69,8 +69,8 @@ describe("Uploads actions", () => {
const expectedActions = [
{
type: "uploads/SHOW_ABORT_MODAL",
show: true,
},
show: true
}
]
store.dispatch(uploadsActions.showAbortModal())
const actions = store.getActions()
@@ -79,15 +79,15 @@ describe("Uploads actions", () => {
describe("uploadFile", () => {
const file = new Blob(["file content"], {
type: "text/plain",
type: "text/plain"
})
file.name = "file1"
it("creates alerts/SET action when currentBucket is not present", () => {
const store = mockStore({
buckets: {
currentBucket: "",
},
currentBucket: ""
}
})
const expectedActions = [
{
@@ -95,12 +95,12 @@ describe("Uploads actions", () => {
alert: {
id: 0,
type: "danger",
message: "Please choose a bucket before trying to upload files.",
},
},
message: "Please choose a bucket before trying to upload files."
}
}
]
const file = new Blob(["file content"], {
type: "text/plain",
type: "text/plain"
})
store.dispatch(uploadsActions.uploadFile(file))
const actions = store.getActions()
@@ -110,19 +110,19 @@ describe("Uploads actions", () => {
it("creates uploads/ADD action before uploading the file", () => {
const store = mockStore({
buckets: {
currentBucket: "test1",
currentBucket: "test1"
},
objects: {
currentPrefix: "pre1/",
},
currentPrefix: "pre1/"
}
})
const expectedActions = [
{
type: "uploads/ADD",
slug: "test1-pre1/-file1",
size: file.size,
name: file.name,
},
name: file.name
}
]
store.dispatch(uploadsActions.uploadFile(file))
const actions = store.getActions()
@@ -137,23 +137,23 @@ describe("Uploads actions", () => {
send: send,
setRequestHeader: jest.fn(),
upload: {
addEventListener: jest.fn(),
},
addEventListener: jest.fn()
}
})
window.XMLHttpRequest = jest.fn().mockImplementation(xhrMockClass)
const store = mockStore({
buckets: {
currentBucket: "test1",
currentBucket: "test1"
},
objects: {
currentPrefix: "pre1/",
},
currentPrefix: "pre1/"
}
})
store.dispatch(uploadsActions.uploadFile(file))
expect(open).toHaveBeenCalledWith(
"PUT",
"https://localhost:8080/upload/test1/pre1/file1",
true,
true
)
expect(send).toHaveBeenCalledWith(file)
})
@@ -164,12 +164,12 @@ describe("Uploads actions", () => {
const expectedActions = [
{
type: "uploads/STOP",
slug: "a-b/-c",
slug: "a-b/-c"
},
{
type: "uploads/SHOW_ABORT_MODAL",
show: false,
},
show: false
}
]
store.dispatch(uploadsActions.abortUpload("a-b/-c"))
const actions = store.getActions()