Commit f2e9d00b authored by Phil Hughes's avatar Phil Hughes

Correctly handle hash for README's in Vue file listing

Closes https://gitlab.com/gitlab-org/gitlab/issues/207253
parent 5145de2d
......@@ -2,6 +2,7 @@
import $ from 'jquery';
import '~/behaviors/markdown/render_gfm';
import { GlLink, GlLoadingIcon } from '@gitlab/ui';
import { handleLocationHash } from '~/lib/utils/common_utils';
import getReadmeQuery from '../../queries/getReadme.query.graphql';
export default {
......@@ -36,6 +37,7 @@ export default {
readme(newVal) {
if (newVal) {
this.$nextTick(() => {
handleLocationHash();
$(this.$refs.readme).renderGFM();
});
}
......
import { shallowMount } from '@vue/test-utils';
import { GlLoadingIcon } from '@gitlab/ui';
import { handleLocationHash } from '~/lib/utils/common_utils';
import Preview from '~/repository/components/preview/index.vue';
jest.mock('~/lib/utils/common_utils');
let vm;
let $apollo;
......@@ -38,6 +41,22 @@ describe('Repository file preview component', () => {
});
});
it('handles hash after render', () => {
factory({
webUrl: 'http://test.com',
name: 'README.md',
});
vm.setData({ readme: { html: '<div class="blob">test</div>' } });
return vm.vm
.$nextTick()
.then(vm.vm.$nextTick())
.then(() => {
expect(handleLocationHash).toHaveBeenCalled();
});
});
it('renders loading icon', () => {
factory({
webUrl: 'http://test.com',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment