debian-mirror-gitlab/spec/frontend/monitoring/pages/dashboard_page_spec.js
2020-06-23 00:09:42 +05:30

36 lines
1,001 B
JavaScript

import { shallowMount } from '@vue/test-utils';
import DashboardPage from '~/monitoring/pages/dashboard_page.vue';
import Dashboard from '~/monitoring/components/dashboard.vue';
import { propsData } from '../mock_data';
describe('monitoring/pages/dashboard_page', () => {
let wrapper;
const buildWrapper = (props = {}) => {
wrapper = shallowMount(DashboardPage, {
propsData: {
...props,
},
});
};
const findDashboardComponent = () => wrapper.find(Dashboard);
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', () => {
buildWrapper({ dashboardProps: propsData });
expect(findDashboardComponent().props()).toMatchObject(propsData);
expect(findDashboardComponent()).toExist();
});
});