debian-mirror-gitlab/spec/javascripts/diffs/components/compare_versions_dropdown_spec.js

35 lines
1 KiB
JavaScript
Raw Normal View History

2019-05-30 16:15:17 +05:30
// TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
2019-03-02 22:35:43 +05:30
import { shallowMount, createLocalVue } from '@vue/test-utils';
import CompareVersionsDropdown from '~/diffs/components/compare_versions_dropdown.vue';
import diffsMockData from '../mock_data/merge_request_diffs';
describe('CompareVersionsDropdown', () => {
let wrapper;
2019-05-30 16:15:17 +05:30
const targetBranch = { branchName: 'tmp-wine-dev', versionIndex: -1 };
2019-03-02 22:35:43 +05:30
2019-05-30 16:15:17 +05:30
const factory = (options = {}) => {
const localVue = createLocalVue();
2019-03-02 22:35:43 +05:30
2019-05-30 16:15:17 +05:30
wrapper = shallowMount(CompareVersionsDropdown, { localVue, ...options });
2019-03-02 22:35:43 +05:30
};
afterEach(() => {
wrapper.destroy();
});
2019-05-30 16:15:17 +05:30
it('should render a correct base version link', () => {
factory({
propsData: {
baseVersionPath: '/gnuwget/wget2/merge_requests/6/diffs?diff_id=37',
2019-03-02 22:35:43 +05:30
otherVersions: diffsMockData.slice(1),
targetBranch,
2019-05-30 16:15:17 +05:30
},
2019-03-02 22:35:43 +05:30
});
2019-05-30 16:15:17 +05:30
const links = wrapper.findAll('a');
const lastLink = links.wrappers[links.length - 1];
2019-03-02 22:35:43 +05:30
2019-05-30 16:15:17 +05:30
expect(lastLink.attributes('href')).toEqual(wrapper.props('baseVersionPath'));
2019-03-02 22:35:43 +05:30
});
});