diff options
Diffstat (limited to 'spec/frontend/import_entities/import_projects/store/mutations_spec.js')
-rw-r--r-- | spec/frontend/import_entities/import_projects/store/mutations_spec.js | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/spec/frontend/import_entities/import_projects/store/mutations_spec.js b/spec/frontend/import_entities/import_projects/store/mutations_spec.js index 77fae951300..7884e9b4307 100644 --- a/spec/frontend/import_entities/import_projects/store/mutations_spec.js +++ b/spec/frontend/import_entities/import_projects/store/mutations_spec.js @@ -27,7 +27,12 @@ describe('import_projects store mutations', () => { state = { filter: 'some-value', repositories: ['some', ' repositories'], - pageInfo: { page: 1 }, + pageInfo: { + page: 1, + startCursor: 'Y3Vyc30yOjI2', + endCursor: 'Y3Vyc29yOjI1', + hasNextPage: false, + }, }; mutations[types.SET_FILTER](state, NEW_VALUE); }); @@ -36,8 +41,11 @@ describe('import_projects store mutations', () => { expect(state.repositories.length).toBe(0); }); - it('resets current page to 0', () => { + it('resets pagintation', () => { expect(state.pageInfo.page).toBe(0); + expect(state.pageInfo.startCursor).toBe(null); + expect(state.pageInfo.endCursor).toBe(null); + expect(state.pageInfo.hasNextPage).toBe(true); }); }); @@ -263,43 +271,6 @@ describe('import_projects store mutations', () => { }); }); - describe(`${types.REQUEST_NAMESPACES}`, () => { - it('sets namespaces loading flag to true', () => { - state = {}; - - mutations[types.REQUEST_NAMESPACES](state); - - expect(state.isLoadingNamespaces).toBe(true); - }); - }); - - describe(`${types.RECEIVE_NAMESPACES_SUCCESS}`, () => { - const response = [{ fullPath: 'some/path' }]; - - beforeEach(() => { - state = {}; - mutations[types.RECEIVE_NAMESPACES_SUCCESS](state, response); - }); - - it('stores namespaces to state', () => { - expect(state.namespaces).toStrictEqual(response); - }); - - it('sets namespaces loading flag to false', () => { - expect(state.isLoadingNamespaces).toBe(false); - }); - }); - - describe(`${types.RECEIVE_NAMESPACES_ERROR}`, () => { - it('sets namespaces loading flag to false', () => { - state = {}; - - mutations[types.RECEIVE_NAMESPACES_ERROR](state); - - expect(state.isLoadingNamespaces).toBe(false); - }); - }); - describe(`${types.SET_IMPORT_TARGET}`, () => { const PROJECT = { id: 2, @@ -345,4 +316,34 @@ describe('import_projects store mutations', () => { expect(state.pageInfo.page).toBe(NEW_PAGE); }); }); + + describe(`${types.SET_PAGE_CURSORS}`, () => { + it('sets page cursors', () => { + const NEW_CURSORS = { startCursor: 'startCur', endCursor: 'endCur', hasNextPage: false }; + state = { pageInfo: { page: 1, startCursor: null, endCursor: null, hasNextPage: true } }; + + mutations[types.SET_PAGE_CURSORS](state, NEW_CURSORS); + expect(state.pageInfo).toEqual({ ...NEW_CURSORS, page: 1 }); + }); + }); + + describe(`${types.CANCEL_IMPORT_SUCCESS}`, () => { + const payload = { repoId: 1 }; + + beforeEach(() => { + state = { + repositories: [ + { + importSource: { id: 1 }, + importedProject: { importStatus: STATUSES.NONE }, + }, + ], + }; + mutations[types.CANCEL_IMPORT_SUCCESS](state, payload); + }); + + it('updates project status', () => { + expect(state.repositories[0].importedProject.importStatus).toBe(STATUSES.CANCELED); + }); + }); }); |