debian-mirror-gitlab/spec/frontend/profile/components/overview_tab_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.3 KiB
JavaScript
Raw Normal View History

2023-06-20 00:43:36 +05:30
import { GlLoadingIcon, GlTab, GlLink } from '@gitlab/ui';
2023-04-23 21:23:45 +05:30
2023-06-20 00:43:36 +05:30
import projects from 'test_fixtures/api/users/projects/get.json';
2023-04-23 21:23:45 +05:30
import { s__ } from '~/locale';
import OverviewTab from '~/profile/components/overview_tab.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
2023-05-27 22:25:52 +05:30
import ActivityCalendar from '~/profile/components/activity_calendar.vue';
2023-06-20 00:43:36 +05:30
import ProjectsList from '~/vue_shared/components/projects_list/projects_list.vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
2023-04-23 21:23:45 +05:30
describe('OverviewTab', () => {
let wrapper;
2023-06-20 00:43:36 +05:30
const defaultPropsData = {
personalProjects: convertObjectPropsToCamelCase(projects, { deep: true }),
personalProjectsLoading: false,
};
const createComponent = ({ propsData = {} } = {}) => {
wrapper = shallowMountExtended(OverviewTab, {
propsData: { ...defaultPropsData, ...propsData },
});
2023-04-23 21:23:45 +05:30
};
it('renders `GlTab` and sets `title` prop', () => {
createComponent();
expect(wrapper.findComponent(GlTab).attributes('title')).toBe(s__('UserProfile|Overview'));
});
2023-05-27 22:25:52 +05:30
it('renders `ActivityCalendar` component', () => {
createComponent();
expect(wrapper.findComponent(ActivityCalendar).exists()).toBe(true);
});
2023-06-20 00:43:36 +05:30
it('renders personal projects section heading and `View all` link', () => {
createComponent();
expect(
wrapper.findByRole('heading', { name: OverviewTab.i18n.personalProjects }).exists(),
).toBe(true);
expect(wrapper.findComponent(GlLink).text()).toBe(OverviewTab.i18n.viewAll);
});
describe('when personal projects are loading', () => {
it('renders loading icon', () => {
createComponent({
propsData: {
personalProjects: [],
personalProjectsLoading: true,
},
});
expect(
wrapper.findByTestId('personal-projects-section').findComponent(GlLoadingIcon).exists(),
).toBe(true);
});
});
describe('when projects are done loading', () => {
it('renders `ProjectsList` component and passes `projects` prop', () => {
createComponent();
expect(
wrapper
.findByTestId('personal-projects-section')
.findComponent(ProjectsList)
.props('projects'),
).toMatchObject(defaultPropsData.personalProjects);
});
});
2023-04-23 21:23:45 +05:30
});