debian-mirror-gitlab/spec/frontend/branches/components/divergence_graph_spec.js

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

68 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-09-30 21:07:59 +05:30
import { shallowMount } from '@vue/test-utils';
import DivergenceGraph from '~/branches/components/divergence_graph.vue';
import GraphBar from '~/branches/components/graph_bar.vue';
let vm;
function factory(propsData = {}) {
vm = shallowMount(DivergenceGraph, { propsData });
}
describe('Branch divergence graph component', () => {
afterEach(() => {
vm.destroy();
});
it('renders ahead and behind count', () => {
factory({
2021-06-08 01:23:25 +05:30
defaultBranch: 'main',
2019-09-30 21:07:59 +05:30
aheadCount: 10,
behindCount: 10,
maxCommits: 100,
});
2022-10-11 01:57:18 +05:30
expect(vm.findAllComponents(GraphBar).length).toBe(2);
2019-09-30 21:07:59 +05:30
expect(vm.element).toMatchSnapshot();
});
it('sets title for ahead and behind count', () => {
factory({
2021-06-08 01:23:25 +05:30
defaultBranch: 'main',
2019-09-30 21:07:59 +05:30
aheadCount: 10,
behindCount: 10,
maxCommits: 100,
});
2021-06-08 01:23:25 +05:30
expect(vm.attributes('title')).toBe('10 commits behind main, 10 commits ahead');
2019-09-30 21:07:59 +05:30
});
it('renders distance count', () => {
factory({
2021-06-08 01:23:25 +05:30
defaultBranch: 'main',
2019-09-30 21:07:59 +05:30
aheadCount: 0,
behindCount: 0,
distance: 900,
maxCommits: 100,
});
2022-10-11 01:57:18 +05:30
expect(vm.findAllComponents(GraphBar).length).toBe(1);
2019-09-30 21:07:59 +05:30
expect(vm.element).toMatchSnapshot();
});
it.each`
distance | titleText
${900} | ${'900'}
${1100} | ${'999+'}
`('sets title for $distance as $titleText', ({ distance, titleText }) => {
factory({
2021-06-08 01:23:25 +05:30
defaultBranch: 'main',
2019-09-30 21:07:59 +05:30
aheadCount: 0,
behindCount: 0,
distance,
maxCommits: 100,
});
2021-06-08 01:23:25 +05:30
expect(vm.attributes('title')).toBe(`More than ${titleText} commits different with main`);
2019-09-30 21:07:59 +05:30
});
});