diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:19 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:19 +0000 |
commit | e6baeabaa9651d90b03bb64ffce75a2c3cb89aab (patch) | |
tree | 85f3cbd6e437b17be59505cf3ac4794c1838609e /spec/frontend/registry/explorer/stores | |
parent | 5064bf8c5647d4c4430cbb4d097cf1592416de29 (diff) | |
download | gitlab-ce-e6baeabaa9651d90b03bb64ffce75a2c3cb89aab.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/registry/explorer/stores')
3 files changed, 70 insertions, 31 deletions
diff --git a/spec/frontend/registry/explorer/stores/actions_spec.js b/spec/frontend/registry/explorer/stores/actions_spec.js index 3e22621058e..b39c79dd1ab 100644 --- a/spec/frontend/registry/explorer/stores/actions_spec.js +++ b/spec/frontend/registry/explorer/stores/actions_spec.js @@ -38,6 +38,17 @@ describe('Actions RegistryExplorer Store', () => { ); }); + it('setShowGarbageCollectionTip', done => { + testAction( + actions.setShowGarbageCollectionTip, + true, + null, + [{ type: types.SET_SHOW_GARBAGE_COLLECTION_TIP, payload: true }], + [], + done, + ); + }); + describe('receives api responses', () => { const response = { data: [1, 2, 3], @@ -183,18 +194,19 @@ describe('Actions RegistryExplorer Store', () => { [{ type: types.SET_MAIN_LOADING, payload: true }], [ { + type: 'setShowGarbageCollectionTip', + payload: true, + }, + { type: 'requestTagsList', payload: { pagination: {}, params }, }, ], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, + done, ); }); - it('should show flash message on error', done => { + it('should turn off loading on error', done => { testAction( actions.requestDeleteTag, { @@ -208,10 +220,7 @@ describe('Actions RegistryExplorer Store', () => { { type: types.SET_MAIN_LOADING, payload: false }, ], [], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, + done, ); }); }); @@ -235,18 +244,19 @@ describe('Actions RegistryExplorer Store', () => { [{ type: types.SET_MAIN_LOADING, payload: true }], [ { + type: 'setShowGarbageCollectionTip', + payload: true, + }, + { type: 'requestTagsList', payload: { pagination: {}, params }, }, ], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, + done, ); }); - it('should show flash message on error', done => { + it('should turn off loading on error', done => { mock.onDelete(url).replyOnce(500); testAction( @@ -263,17 +273,14 @@ describe('Actions RegistryExplorer Store', () => { { type: types.SET_MAIN_LOADING, payload: false }, ], [], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, + done, ); }); }); describe('request delete single image', () => { + const deletePath = 'delete/path'; it('successfully performs the delete request', done => { - const deletePath = 'delete/path'; mock.onDelete(deletePath).replyOnce(200); testAction( @@ -288,32 +295,32 @@ describe('Actions RegistryExplorer Store', () => { ], [ { + type: 'setShowGarbageCollectionTip', + payload: true, + }, + { type: 'requestImagesList', payload: { pagination: {} }, }, ], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, + done, ); }); - it('should show flash message on error', done => { + it('should turn off loading on error', done => { + mock.onDelete(deletePath).replyOnce(400); testAction( actions.requestDeleteImage, - null, + deletePath, {}, [ { type: types.SET_MAIN_LOADING, payload: true }, { type: types.SET_MAIN_LOADING, payload: false }, ], [], - () => { - expect(createFlash).toHaveBeenCalled(); - done(); - }, - ); + ).catch(() => { + done(); + }); }); }); }); diff --git a/spec/frontend/registry/explorer/stores/getters_spec.js b/spec/frontend/registry/explorer/stores/getters_spec.js index 211b8169d82..cd053ea8edc 100644 --- a/spec/frontend/registry/explorer/stores/getters_spec.js +++ b/spec/frontend/registry/explorer/stores/getters_spec.js @@ -49,4 +49,22 @@ describe('Getters RegistryExplorer store', () => { expect(getters[getter](state)).toBe(expectedPieces.join(' ')); }); }); + + describe('showGarbageCollection', () => { + it.each` + result | showGarbageCollectionTip | isAdmin + ${true} | ${true} | ${true} + ${false} | ${true} | ${false} + ${false} | ${false} | ${true} + `( + 'return $result when showGarbageCollectionTip $showGarbageCollectionTip and isAdmin is $isAdmin', + ({ result, showGarbageCollectionTip, isAdmin }) => { + state = { + config: { isAdmin }, + showGarbageCollectionTip, + }; + expect(getters.showGarbageCollection(state)).toBe(result); + }, + ); + }); }); diff --git a/spec/frontend/registry/explorer/stores/mutations_spec.js b/spec/frontend/registry/explorer/stores/mutations_spec.js index 1d5055c02d2..029fd23f7ce 100644 --- a/spec/frontend/registry/explorer/stores/mutations_spec.js +++ b/spec/frontend/registry/explorer/stores/mutations_spec.js @@ -10,7 +10,12 @@ describe('Mutations Registry Explorer Store', () => { describe('SET_INITIAL_STATE', () => { it('should set the initial state', () => { - const payload = { endpoint: 'foo', isGroupPage: true, expirationPolicy: { foo: 'bar' } }; + const payload = { + endpoint: 'foo', + isGroupPage: true, + expirationPolicy: { foo: 'bar' }, + isAdmin: true, + }; const expectedState = { ...mockState, config: payload }; mutations[types.SET_INITIAL_STATE](mockState, { ...payload, @@ -50,6 +55,15 @@ describe('Mutations Registry Explorer Store', () => { }); }); + describe('SET_SHOW_GARBAGE_COLLECTION_TIP', () => { + it('should set the showGarbageCollectionTip', () => { + const expectedState = { ...mockState, showGarbageCollectionTip: true }; + mutations[types.SET_SHOW_GARBAGE_COLLECTION_TIP](mockState, true); + + expect(mockState).toEqual(expectedState); + }); + }); + describe('SET_PAGINATION', () => { const generatePagination = () => [ { |