diff options
Diffstat (limited to 'spec/frontend/repository/components/preview/index_spec.js')
-rw-r--r-- | spec/frontend/repository/components/preview/index_spec.js | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/spec/frontend/repository/components/preview/index_spec.js b/spec/frontend/repository/components/preview/index_spec.js index 2490258a048..0d9bfc62ed5 100644 --- a/spec/frontend/repository/components/preview/index_spec.js +++ b/spec/frontend/repository/components/preview/index_spec.js @@ -1,5 +1,6 @@ import { GlLoadingIcon } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; +import { nextTick } from 'vue'; import { handleLocationHash } from '~/lib/utils/common_utils'; import Preview from '~/repository/components/preview/index.vue'; @@ -28,7 +29,7 @@ describe('Repository file preview component', () => { vm.destroy(); }); - it('renders file HTML', () => { + it('renders file HTML', async () => { factory({ webPath: 'http://test.com', name: 'README.md', @@ -38,12 +39,11 @@ describe('Repository file preview component', () => { // eslint-disable-next-line no-restricted-syntax vm.setData({ readme: { html: '<div class="blob">test</div>' } }); - return vm.vm.$nextTick(() => { - expect(vm.element).toMatchSnapshot(); - }); + await nextTick(); + expect(vm.element).toMatchSnapshot(); }); - it('handles hash after render', () => { + it('handles hash after render', async () => { factory({ webPath: 'http://test.com', name: 'README.md', @@ -53,15 +53,11 @@ describe('Repository file preview component', () => { // eslint-disable-next-line no-restricted-syntax vm.setData({ readme: { html: '<div class="blob">test</div>' } }); - return vm.vm - .$nextTick() - .then(vm.vm.$nextTick()) - .then(() => { - expect(handleLocationHash).toHaveBeenCalled(); - }); + await nextTick(); + expect(handleLocationHash).toHaveBeenCalled(); }); - it('renders loading icon', () => { + it('renders loading icon', async () => { factory({ webPath: 'http://test.com', name: 'README.md', @@ -71,8 +67,7 @@ describe('Repository file preview component', () => { // eslint-disable-next-line no-restricted-syntax vm.setData({ loading: 1 }); - return vm.vm.$nextTick(() => { - expect(vm.find(GlLoadingIcon).exists()).toBe(true); - }); + await nextTick(); + expect(vm.find(GlLoadingIcon).exists()).toBe(true); }); }); |