diff options
Diffstat (limited to 'spec/frontend/repository/components/table/index_spec.js')
-rw-r--r-- | spec/frontend/repository/components/table/index_spec.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js index 10669330b61..1b8bbd5af6b 100644 --- a/spec/frontend/repository/components/table/index_spec.js +++ b/spec/frontend/repository/components/table/index_spec.js @@ -1,5 +1,5 @@ import { shallowMount } from '@vue/test-utils'; -import { GlSkeletonLoading } from '@gitlab/ui'; +import { GlDeprecatedSkeletonLoading as GlSkeletonLoading, GlButton } from '@gitlab/ui'; import Table from '~/repository/components/table/index.vue'; import TableRow from '~/repository/components/table/row.vue'; @@ -34,12 +34,13 @@ const MOCK_BLOBS = [ }, ]; -function factory({ path, isLoading = false, entries = {} }) { +function factory({ path, isLoading = false, hasMore = true, entries = {} }) { vm = shallowMount(Table, { propsData: { path, isLoading, entries, + hasMore, }, mocks: { $apollo, @@ -88,4 +89,27 @@ describe('Repository table component', () => { expect(rows.length).toEqual(3); expect(rows.at(2).attributes().mode).toEqual('120000'); }); + + describe('Show more button', () => { + const showMoreButton = () => vm.find(GlButton); + + it.each` + hasMore | expectButtonToExist + ${true} | ${true} + ${false} | ${false} + `('renders correctly', ({ hasMore, expectButtonToExist }) => { + factory({ path: '/', hasMore }); + expect(showMoreButton().exists()).toBe(expectButtonToExist); + }); + + it('when is clicked, emits showMore event', async () => { + factory({ path: '/' }); + + showMoreButton().vm.$emit('click'); + + await vm.vm.$nextTick(); + + expect(vm.emitted('showMore')).toHaveLength(1); + }); + }); }); |