diff options
Diffstat (limited to 'spec/frontend/repository/components/table/index_spec.js')
-rw-r--r-- | spec/frontend/repository/components/table/index_spec.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/frontend/repository/components/table/index_spec.js b/spec/frontend/repository/components/table/index_spec.js new file mode 100644 index 00000000000..6f52cffe077 --- /dev/null +++ b/spec/frontend/repository/components/table/index_spec.js @@ -0,0 +1,47 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlLoadingIcon } from '@gitlab/ui'; +import Table from '~/repository/components/table/index.vue'; + +let vm; + +function factory(path, loading = false) { + vm = shallowMount(Table, { + propsData: { + path, + }, + mocks: { + $apollo: { + queries: { + files: { loading }, + }, + }, + }, + }); +} + +describe('Repository table component', () => { + afterEach(() => { + vm.destroy(); + }); + + it.each` + path | ref + ${'/'} | ${'master'} + ${'app/assets'} | ${'master'} + ${'/'} | ${'test'} + `('renders table caption for $ref in $path', ({ path, ref }) => { + factory(path); + + vm.setData({ ref }); + + expect(vm.find('caption').text()).toEqual( + `Files, directories, and submodules in the path ${path} for commit reference ${ref}`, + ); + }); + + it('renders loading icon', () => { + factory('/', true); + + expect(vm.find(GlLoadingIcon).exists()).toBe(true); + }); +}); |