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

@@ -23,21 +23,21 @@ import web from "../../web"
jest.mock("../../web", () => ({
SetBucketPolicy: jest.fn(() => {
return Promise.resolve()
}),
})
}))
describe("PolicyInput", () => {
it("should render without crashing", () => {
const fetchPolicies = jest.fn()
shallow(
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />,
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />
)
})
it("should call fetchPolicies after the component has mounted", () => {
const fetchPolicies = jest.fn()
const wrapper = shallow(
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />,
<PolicyInput currentBucket={"bucket"} fetchPolicies={fetchPolicies} />
)
setImmediate(() => {
expect(fetchPolicies).toHaveBeenCalled()
@@ -51,22 +51,22 @@ describe("PolicyInput", () => {
currentBucket={"bucket"}
policies={[]}
fetchPolicies={fetchPolicies}
/>,
/>
)
wrapper.instance().prefix = {
value: "baz",
value: "baz"
}
wrapper.instance().policy = {
value: READ_ONLY,
value: READ_ONLY
}
wrapper.find("button").simulate("click", {
preventDefault: jest.fn(),
preventDefault: jest.fn()
})
expect(web.SetBucketPolicy).toHaveBeenCalledWith({
bucketName: "bucket",
prefix: "baz",
policy: READ_ONLY,
policy: READ_ONLY
})
setImmediate(() => {
@@ -81,21 +81,21 @@ describe("PolicyInput", () => {
currentBucket={"bucket"}
policies={[]}
fetchPolicies={fetchPolicies}
/>,
/>
)
wrapper.instance().prefix = {
value: "*",
value: "*"
}
wrapper.instance().policy = {
value: READ_ONLY,
value: READ_ONLY
}
wrapper.find("button").simulate("click", {
preventDefault: jest.fn(),
preventDefault: jest.fn()
})
expect(wrapper.instance().prefix).toEqual({
value: "",
value: ""
})
})
})