debian-mirror-gitlab/spec/frontend/monitoring/pages/dashboard_page_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.6 KiB
JavaScript
Raw Normal View History

2020-06-23 00:09:42 +05:30
import { shallowMount } from '@vue/test-utils';
import Dashboard from '~/monitoring/components/dashboard.vue';
2021-03-11 19:13:27 +05:30
import DashboardPage from '~/monitoring/pages/dashboard_page.vue';
import { createStore } from '~/monitoring/stores';
2020-07-28 23:09:34 +05:30
import { dashboardProps } from '../fixture_data';
2020-06-23 00:09:42 +05:30
describe('monitoring/pages/dashboard_page', () => {
let wrapper;
2020-07-28 23:09:34 +05:30
let store;
let $route;
const buildRouter = () => {
const dashboard = {};
$route = {
params: { dashboard },
query: { dashboard },
};
};
2020-06-23 00:09:42 +05:30
const buildWrapper = (props = {}) => {
wrapper = shallowMount(DashboardPage, {
2020-07-28 23:09:34 +05:30
store,
2020-06-23 00:09:42 +05:30
propsData: {
...props,
},
2020-07-28 23:09:34 +05:30
mocks: {
$route,
},
2020-06-23 00:09:42 +05:30
});
};
2021-12-11 22:18:48 +05:30
const findDashboardComponent = () => wrapper.findComponent(Dashboard);
2020-06-23 00:09:42 +05:30
2020-07-28 23:09:34 +05:30
beforeEach(() => {
buildRouter();
store = createStore();
jest.spyOn(store, 'dispatch').mockResolvedValue();
});
2020-06-23 00:09:42 +05:30
afterEach(() => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
});
it('throws errors if dashboard props are not passed', () => {
expect(() => buildWrapper()).toThrow('Missing required prop: "dashboardProps"');
});
it('renders the dashboard page with dashboard component', () => {
2020-07-28 23:09:34 +05:30
buildWrapper({ dashboardProps });
const allProps = {
...dashboardProps,
// default props values
rearrangePanelsAvailable: false,
showHeader: true,
showPanels: true,
smallEmptyState: false,
};
2020-06-23 00:09:42 +05:30
2021-12-11 22:18:48 +05:30
expect(findDashboardComponent().exists()).toBe(true);
2020-07-28 23:09:34 +05:30
expect(allProps).toMatchObject(findDashboardComponent().props());
2020-06-23 00:09:42 +05:30
});
});