-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dashbar add fetch data (#1617)
- Loading branch information
Showing
8 changed files
with
170 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,66 @@ | ||
import Dashbar from './Dashbar'; | ||
import { Card, Grid } from '@patternfly/react-core'; | ||
import toJson from 'enzyme-to-json'; | ||
import { mountWithIntl } from '../../../Helpers/MiscHelper'; | ||
import { Provider } from 'react-redux'; | ||
import configureStore from 'redux-mock-store'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
import Dashbar from "./Dashbar"; | ||
import { Card, Grid } from "@patternfly/react-core"; | ||
import toJson from "enzyme-to-json"; | ||
import { mountWithIntl } from "../../../Helpers/MiscHelper"; | ||
import { Provider } from "react-redux"; | ||
import configureStore from "redux-mock-store"; | ||
import { BrowserRouter as Router } from "react-router-dom"; | ||
import { DashbarItem } from './Dashbar' | ||
|
||
jest.mock("react-redux", () => ({ | ||
...jest.requireActual("react-redux"), | ||
useSelector: jest.fn() | ||
useSelector: jest.fn(), | ||
})); | ||
|
||
const mockStore = configureStore([store => next => action => { }]); | ||
const mockStore = configureStore([(store) => (next) => (action) => { }]); | ||
let store = mockStore({}); | ||
|
||
jest.mock('../../../Helpers/MiscHelper', () => ({ | ||
...jest.requireActual('../../../Helpers/MiscHelper'), | ||
useUrlParams: () => [{ dashbar: "true" }, jest.fn()] | ||
jest.mock("../../../Helpers/MiscHelper", () => ({ | ||
...jest.requireActual("../../../Helpers/MiscHelper"), | ||
useUrlParams: () => [{ dashbar: "true" }, jest.fn()], | ||
})); | ||
|
||
|
||
jest.mock("../../../Helpers/APIHelper", () => ({ | ||
...jest.requireActual("../../../Helpers/APIHelper"), | ||
getAnnouncement: () => new Promise((resolve) => resolve({ message: "Message test!" })), | ||
getDashbar: () => new Promise((resolve) => resolve({ exploitable_cves: 1, cves_with_rule: 2, critical_cves: 3, important_cves: 4 })) | ||
})) | ||
|
||
describe('Dashbar', () => { | ||
it('Should match the snapshot', () => { | ||
const wrapper = mountWithIntl( | ||
describe("Dashbar", () => { | ||
it("Should match the snapshot", async () => { | ||
|
||
const wrapper = await mountWithIntl( | ||
<Provider store={store}> | ||
<Router> | ||
<Dashbar /> | ||
</Router> | ||
</Provider>); | ||
</Provider> | ||
); | ||
wrapper.update() | ||
expect(toJson(wrapper)).toMatchSnapshot(); | ||
}) | ||
it('Should render Grid with props hasGutter = true', () => { | ||
const wrapper = mountWithIntl( | ||
}); | ||
it("Should render Grid with props hasGutter = true", async () => { | ||
const wrapper = await mountWithIntl( | ||
<Provider store={store}> | ||
<Router> | ||
<Dashbar /> | ||
</Router> | ||
</Provider> | ||
); | ||
wrapper.update() | ||
expect(wrapper.find(Grid)).toHaveLength(1); | ||
expect(wrapper.find(Grid).prop('hasGutter')).toBeTruthy(); | ||
expect(wrapper.find(Grid).prop("hasGutter")).toBeTruthy(); | ||
}); | ||
it('Should have 4 card items', () => { | ||
const wrapper = mountWithIntl( | ||
it("Should have 4 DashbarItems", async () => { | ||
const wrapper = await mountWithIntl( | ||
<Provider store={store}> | ||
<Router> | ||
<Dashbar /> | ||
</Router> | ||
</Provider> | ||
); | ||
expect(wrapper.find(Card)).toHaveLength(4); | ||
}) | ||
}) | ||
wrapper.update() | ||
expect(wrapper.find(DashbarItem)).toHaveLength(4); | ||
}); | ||
}); |
Oops, something went wrong.