From 92d911460ec3e84ebe2efd5ae68bf530bf9aaa61 Mon Sep 17 00:00:00 2001
From: Adam Alvis <adam.alvis@gmail.com>
Date: Tue, 23 Jun 2020 14:07:50 -0400
Subject: [PATCH] added unit tests for security dashboard emptystate

---
 ..._class_instance_security_dashboard_spec.js | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 ee/spec/frontend/security_dashboard/components/empty_states/first_class_instance_security_dashboard_spec.js

diff --git a/ee/spec/frontend/security_dashboard/components/empty_states/first_class_instance_security_dashboard_spec.js b/ee/spec/frontend/security_dashboard/components/empty_states/first_class_instance_security_dashboard_spec.js
new file mode 100644
index 00000000000..1a8f91b33a9
--- /dev/null
+++ b/ee/spec/frontend/security_dashboard/components/empty_states/first_class_instance_security_dashboard_spec.js
@@ -0,0 +1,52 @@
+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);
+  });
+});
-- 
2.30.9