summaryrefslogtreecommitdiff
path: root/spec/frontend/integrations/index/components/integrations_table_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/integrations/index/components/integrations_table_spec.js')
-rw-r--r--spec/frontend/integrations/index/components/integrations_table_spec.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/frontend/integrations/index/components/integrations_table_spec.js b/spec/frontend/integrations/index/components/integrations_table_spec.js
new file mode 100644
index 00000000000..bfe0a5987b4
--- /dev/null
+++ b/spec/frontend/integrations/index/components/integrations_table_spec.js
@@ -0,0 +1,53 @@
+import { GlTable, GlIcon } from '@gitlab/ui';
+import { mount } from '@vue/test-utils';
+import IntegrationsTable from '~/integrations/index/components/integrations_table.vue';
+import TimeAgoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
+
+import { mockActiveIntegrations, mockInactiveIntegrations } from '../mock_data';
+
+describe('IntegrationsTable', () => {
+ let wrapper;
+
+ const findTable = () => wrapper.findComponent(GlTable);
+
+ const createComponent = (propsData = {}) => {
+ wrapper = mount(IntegrationsTable, {
+ propsData: {
+ integrations: mockActiveIntegrations,
+ ...propsData,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ describe.each([true, false])('when `showUpdatedAt` is %p', (showUpdatedAt) => {
+ beforeEach(() => {
+ createComponent({ showUpdatedAt });
+ });
+
+ it(`${showUpdatedAt ? 'renders' : 'does not render'} content in "Last updated" column`, () => {
+ const headers = findTable().findAll('th');
+ expect(headers.wrappers.some((header) => header.text() === 'Last updated')).toBe(
+ showUpdatedAt,
+ );
+ expect(wrapper.findComponent(TimeAgoTooltip).exists()).toBe(showUpdatedAt);
+ });
+ });
+
+ describe.each`
+ scenario | integrations | shouldRenderActiveIcon
+ ${'when integration is active'} | ${[mockActiveIntegrations[0]]} | ${true}
+ ${'when integration is inactive'} | ${[mockInactiveIntegrations[0]]} | ${false}
+ `('$scenario', ({ shouldRenderActiveIcon, integrations }) => {
+ beforeEach(() => {
+ createComponent({ integrations });
+ });
+
+ it(`${shouldRenderActiveIcon ? 'renders' : 'does not render'} icon in first column`, () => {
+ expect(findTable().findComponent(GlIcon).exists()).toBe(shouldRenderActiveIcon);
+ });
+ });
+});