diff options
Diffstat (limited to 'spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js')
-rw-r--r-- | spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js index 92d064846bd..056155a560f 100644 --- a/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js +++ b/spec/frontend/import_entities/import_projects/components/import_projects_table_spec.js @@ -36,6 +36,7 @@ describe('ImportProjectsTable', () => { .filter((w) => w.props().variant === 'confirm') .at(0); const findImportAllModal = () => wrapper.findComponent({ ref: 'importAllModal' }); + const findIntersectionObserver = () => wrapper.findComponent(GlIntersectionObserver); const importAllFn = jest.fn(); const importAllModalShowFn = jest.fn(); @@ -203,13 +204,13 @@ describe('ImportProjectsTable', () => { describe('when paginatable is set to true', () => { const initState = { namespaces: [{ fullPath: 'path' }], - pageInfo: { page: 1, hasNextPage: true }, + pageInfo: { page: 1, hasNextPage: false }, repositories: [ { importSource: { id: 1 }, importedProject: null, importStatus: STATUSES.NONE }, ], }; - describe('with hasNextPage true', () => { + describe('with hasNextPage false', () => { beforeEach(() => { createComponent({ state: initState, @@ -217,26 +218,14 @@ describe('ImportProjectsTable', () => { }); }); - it('does not call fetchRepos on mount', () => { - expect(fetchReposFn).not.toHaveBeenCalled(); - }); - - it('renders intersection observer component', () => { - expect(wrapper.findComponent(GlIntersectionObserver).exists()).toBe(true); - }); - - it('calls fetchRepos when intersection observer appears', async () => { - wrapper.findComponent(GlIntersectionObserver).vm.$emit('appear'); - - await nextTick(); - - expect(fetchReposFn).toHaveBeenCalled(); + it('does not render intersection observer component', () => { + expect(findIntersectionObserver().exists()).toBe(false); }); }); - describe('with hasNextPage false', () => { + describe('with hasNextPage true', () => { beforeEach(() => { - initState.pageInfo.hasNextPage = false; + initState.pageInfo.hasNextPage = true; createComponent({ state: initState, @@ -244,8 +233,16 @@ describe('ImportProjectsTable', () => { }); }); - it('does not render intersection observer component', () => { - expect(wrapper.findComponent(GlIntersectionObserver).exists()).toBe(false); + it('renders intersection observer component', () => { + expect(findIntersectionObserver().exists()).toBe(true); + }); + + it('calls fetchRepos again when intersection observer appears', async () => { + findIntersectionObserver().vm.$emit('appear'); + + await nextTick(); + + expect(fetchReposFn).toHaveBeenCalledTimes(2); }); }); }); |