Commit 873d6a78 authored by Justin Ho's avatar Justin Ho

Add more specs to cover all logic

Make sure badge count is rendered properly when
value is null / present.
parent 33bc9b78
...@@ -5,6 +5,8 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -5,6 +5,8 @@ import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { DEFAULT_PER_PAGE } from '~/api'; import { DEFAULT_PER_PAGE } from '~/api';
import IntegrationOverrides from '~/integrations/overrides/components/integration_overrides.vue'; import IntegrationOverrides from '~/integrations/overrides/components/integration_overrides.vue';
import IntegrationTabs from '~/integrations/overrides/components/integration_tabs.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import ProjectAvatar from '~/vue_shared/components/project_avatar.vue'; import ProjectAvatar from '~/vue_shared/components/project_avatar.vue';
...@@ -49,6 +51,7 @@ describe('IntegrationOverrides', () => { ...@@ -49,6 +51,7 @@ describe('IntegrationOverrides', () => {
const findGlTable = () => wrapper.findComponent(GlTable); const findGlTable = () => wrapper.findComponent(GlTable);
const findPagination = () => wrapper.findComponent(GlPagination); const findPagination = () => wrapper.findComponent(GlPagination);
const findIntegrationTabs = () => wrapper.findComponent(IntegrationTabs);
const findRowsAsModel = () => const findRowsAsModel = () =>
findGlTable() findGlTable()
.findAllComponents(GlLink) .findAllComponents(GlLink)
...@@ -72,6 +75,12 @@ describe('IntegrationOverrides', () => { ...@@ -72,6 +75,12 @@ describe('IntegrationOverrides', () => {
expect(table.exists()).toBe(true); expect(table.exists()).toBe(true);
expect(table.attributes('busy')).toBe('true'); expect(table.attributes('busy')).toBe('true');
}); });
it('renders IntegrationTabs with count as `null`', () => {
createComponent();
expect(findIntegrationTabs().props('projectOverridesCount')).toBe(null);
});
}); });
describe('when initial request is successful', () => { describe('when initial request is successful', () => {
...@@ -84,6 +93,13 @@ describe('IntegrationOverrides', () => { ...@@ -84,6 +93,13 @@ describe('IntegrationOverrides', () => {
expect(table.attributes('busy')).toBeFalsy(); expect(table.attributes('busy')).toBeFalsy();
}); });
it('renders IntegrationTabs with count', async () => {
createComponent();
await waitForPromises();
expect(findIntegrationTabs().props('projectOverridesCount')).toBe(mockOverrides.length);
});
describe('table template', () => { describe('table template', () => {
beforeEach(async () => { beforeEach(async () => {
createComponent({ mountFn: mount }); createComponent({ mountFn: mount });
......
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { GlTab } from '@gitlab/ui'; import { GlBadge, GlTab } from '@gitlab/ui';
import IntegrationTabs from '~/integrations/overrides/components/integration_tabs.vue'; import IntegrationTabs from '~/integrations/overrides/components/integration_tabs.vue';
import { settingsTabTitle, overridesTabTitle } from '~/integrations/constants'; import { settingsTabTitle, overridesTabTitle } from '~/integrations/constants';
...@@ -25,6 +25,7 @@ describe('IntegrationTabs', () => { ...@@ -25,6 +25,7 @@ describe('IntegrationTabs', () => {
wrapper.destroy(); wrapper.destroy();
}); });
const findGlBadge = () => wrapper.findComponent(GlBadge);
const findGlTab = () => wrapper.findComponent(GlTab); const findGlTab = () => wrapper.findComponent(GlTab);
const findSettingsLink = () => wrapper.find('a'); const findSettingsLink = () => wrapper.find('a');
...@@ -47,6 +48,17 @@ describe('IntegrationTabs', () => { ...@@ -47,6 +48,17 @@ describe('IntegrationTabs', () => {
expect(findGlTab().text()).toMatchInterpolatedText( expect(findGlTab().text()).toMatchInterpolatedText(
`${overridesTabTitle} ${projectOverridesCount}`, `${overridesTabTitle} ${projectOverridesCount}`,
); );
expect(findGlBadge().text()).toBe(projectOverridesCount);
});
describe('when count is `null', () => {
it('renders "Projects using custom settings" tab without count', () => {
createComponent();
expect(findGlTab().exists()).toBe(true);
expect(findGlTab().text()).toMatchInterpolatedText(overridesTabTitle);
expect(findGlBadge().exists()).toBe(false);
});
}); });
}); });
}); });
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