Commit 92d91146 authored by Adam Alvis's avatar Adam Alvis

added unit tests for security dashboard emptystate

parent 857cced2
import { mount } from '@vue/test-utils';
import { GlEmptyState, GlButton, GlLink } from '@gitlab/ui';
import EmptyState from 'ee/security_dashboard/components/empty_states/first_class_instance_security_dashboard.vue';
describe('first class instance security dashboard empty state', () => {
let wrapper;
const dashboardDocumentation = '/path/to/dashboard/documentation';
const svgPath = '/placeholder.svg';
const createWrapper = () => mount(EmptyState, {
propsData: { svgPath, dashboardDocumentation },
});
const findGlEmptyState = () => wrapper.find(GlEmptyState);
const findButton = () => wrapper.find(GlButton);
const findLink = () => wrapper.find(GlLink);
beforeEach(() => {
wrapper = createWrapper();
});
afterEach(() => {
wrapper.destroy();
});
it('should render correctly', () => {
expect(wrapper.props()).toEqual({
svgPath,
dashboardDocumentation,
});
});
it('contains a GlEmptyState', () => {
expect(findGlEmptyState().exists()).toEqual(true);
});
it('contains a GlLink with href attribute equal to dashboardDocumentation', () => {
expect(findLink().attributes('href')).toEqual(dashboardDocumentation);
});
it('contains a GlButton', () => {
expect(findButton().exists()).toEqual(true);
});
it('emits `handleAddProjectsClick` on button click', async () => {
const eventName = 'handleAddProjectsClick';
findButton().trigger('click');
await wrapper.vm.$nextTick();
expect(wrapper.emitted()).toHaveProperty(eventName);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment