2019-06-24 07:51:40 -04:00
|
|
|
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-04-26 20:10:25 -04:00
|
|
|
defaultBranch: 'main',
|
2019-06-24 07:51:40 -04:00
|
|
|
aheadCount: 10,
|
|
|
|
behindCount: 10,
|
|
|
|
maxCommits: 100,
|
|
|
|
});
|
|
|
|
|
2022-09-13 14:12:21 -04:00
|
|
|
expect(vm.findAllComponents(GraphBar).length).toBe(2);
|
2019-06-24 07:51:40 -04:00
|
|
|
expect(vm.element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sets title for ahead and behind count', () => {
|
|
|
|
factory({
|
2021-04-26 20:10:25 -04:00
|
|
|
defaultBranch: 'main',
|
2019-06-24 07:51:40 -04:00
|
|
|
aheadCount: 10,
|
|
|
|
behindCount: 10,
|
|
|
|
maxCommits: 100,
|
|
|
|
});
|
|
|
|
|
2021-04-26 20:10:25 -04:00
|
|
|
expect(vm.attributes('title')).toBe('10 commits behind main, 10 commits ahead');
|
2019-06-24 07:51:40 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders distance count', () => {
|
|
|
|
factory({
|
2021-04-26 20:10:25 -04:00
|
|
|
defaultBranch: 'main',
|
2019-06-24 07:51:40 -04:00
|
|
|
aheadCount: 0,
|
|
|
|
behindCount: 0,
|
|
|
|
distance: 900,
|
|
|
|
maxCommits: 100,
|
|
|
|
});
|
|
|
|
|
2022-09-13 14:12:21 -04:00
|
|
|
expect(vm.findAllComponents(GraphBar).length).toBe(1);
|
2019-06-24 07:51:40 -04:00
|
|
|
expect(vm.element).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
distance | titleText
|
|
|
|
${900} | ${'900'}
|
|
|
|
${1100} | ${'999+'}
|
|
|
|
`('sets title for $distance as $titleText', ({ distance, titleText }) => {
|
|
|
|
factory({
|
2021-04-26 20:10:25 -04:00
|
|
|
defaultBranch: 'main',
|
2019-06-24 07:51:40 -04:00
|
|
|
aheadCount: 0,
|
|
|
|
behindCount: 0,
|
|
|
|
distance,
|
|
|
|
maxCommits: 100,
|
|
|
|
});
|
|
|
|
|
2021-04-26 20:10:25 -04:00
|
|
|
expect(vm.attributes('title')).toBe(`More than ${titleText} commits different with main`);
|
2019-06-24 07:51:40 -04:00
|
|
|
});
|
|
|
|
});
|