debian-mirror-gitlab/spec/frontend/groups/components/item_stats_spec.js

51 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { shallowMount } from '@vue/test-utils';
import ItemStats from '~/groups/components/item_stats.vue';
import ItemStatsValue from '~/groups/components/item_stats_value.vue';
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
import { mockParentGroupItem, ITEM_TYPE } from '../mock_data';
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
describe('ItemStats', () => {
let wrapper;
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
const defaultProps = {
item: mockParentGroupItem,
};
2018-12-13 13:39:08 +05:30
2021-01-03 14:25:43 +05:30
const createComponent = (props = {}) => {
wrapper = shallowMount(ItemStats, {
propsData: { ...defaultProps, ...props },
2018-03-17 18:26:18 +05:30
});
2021-01-03 14:25:43 +05:30
};
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
afterEach(() => {
if (wrapper) {
wrapper.destroy();
wrapper = null;
}
2018-03-17 18:26:18 +05:30
});
2021-01-03 14:25:43 +05:30
const findItemStatsValue = () => wrapper.find(ItemStatsValue);
2018-03-17 18:26:18 +05:30
describe('template', () => {
it('renders component container element correctly', () => {
2021-01-03 14:25:43 +05:30
createComponent();
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
expect(wrapper.classes()).toContain('stats');
2018-03-17 18:26:18 +05:30
});
it('renders start count and last updated information for project item correctly', () => {
2021-01-03 14:25:43 +05:30
const item = {
...mockParentGroupItem,
type: ITEM_TYPE.PROJECT,
starCount: 4,
};
2018-12-13 13:39:08 +05:30
2021-01-03 14:25:43 +05:30
createComponent({ item });
2018-03-17 18:26:18 +05:30
2021-01-03 14:25:43 +05:30
expect(findItemStatsValue().exists()).toBe(true);
expect(findItemStatsValue().props('cssClass')).toBe('project-stars');
expect(wrapper.contains('.last-updated')).toBe(true);
2018-03-17 18:26:18 +05:30
});
});
});