diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-04 15:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-04 15:09:14 +0300 |
commit | 8a9cbfa9c56792d8e338c289eb803fb0ebde2083 (patch) | |
tree | fa5ff83fa919ae9a1c37cd8146b78a4a04c9ab7c /spec/frontend/registry | |
parent | fc7ce8aea5b2eca1aaf510667c79b3e7e72f2f3f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/registry')
-rw-r--r-- | spec/frontend/registry/explorer/stores/actions_spec.js | 44 | ||||
-rw-r--r-- | spec/frontend/registry/explorer/stores/mutations_spec.js | 9 | ||||
-rw-r--r-- | spec/frontend/registry/explorer/utils_spec.js | 19 |
3 files changed, 71 insertions, 1 deletions
diff --git a/spec/frontend/registry/explorer/stores/actions_spec.js b/spec/frontend/registry/explorer/stores/actions_spec.js index fb93ab06ca8..66efbf6446b 100644 --- a/spec/frontend/registry/explorer/stores/actions_spec.js +++ b/spec/frontend/registry/explorer/stores/actions_spec.js @@ -1,10 +1,11 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'helpers/test_constants'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; +import Api from '~/api'; import axios from '~/lib/utils/axios_utils'; import * as actions from '~/registry/explorer/stores/actions'; import * as types from '~/registry/explorer/stores/mutation_types'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; import { reposServerResponse, registryServerResponse } from '../mock_data'; jest.mock('~/flash.js'); @@ -227,6 +228,47 @@ describe('Actions RegistryExplorer Store', () => { }); }); + describe('requestImageDetailsAndTagsList', () => { + it('sets the imageDetails and dispatch requestTagsList', done => { + const resolvedValue = { foo: 'bar' }; + jest.spyOn(Api, 'containerRegistryDetails').mockResolvedValue({ data: resolvedValue }); + + testAction( + actions.requestImageDetailsAndTagsList, + 1, + {}, + [ + { type: types.SET_MAIN_LOADING, payload: true }, + { type: types.SET_IMAGE_DETAILS, payload: resolvedValue }, + ], + [ + { + type: 'requestTagsList', + }, + ], + done, + ); + }); + + it('should create flash on error', done => { + jest.spyOn(Api, 'containerRegistryDetails').mockRejectedValue(); + testAction( + actions.requestImageDetailsAndTagsList, + 1, + {}, + [ + { type: types.SET_MAIN_LOADING, payload: true }, + { type: types.SET_MAIN_LOADING, payload: false }, + ], + [], + () => { + expect(createFlash).toHaveBeenCalled(); + done(); + }, + ); + }); + }); + describe('request delete multiple tags', () => { const url = `project-path/registry/repository/foo/tags`; const params = window.btoa(JSON.stringify({ tags_path: `${url}?format=json` })); diff --git a/spec/frontend/registry/explorer/stores/mutations_spec.js b/spec/frontend/registry/explorer/stores/mutations_spec.js index 4ca0211cdc3..1908d3f0350 100644 --- a/spec/frontend/registry/explorer/stores/mutations_spec.js +++ b/spec/frontend/registry/explorer/stores/mutations_spec.js @@ -121,4 +121,13 @@ describe('Mutations Registry Explorer Store', () => { expect(mockState).toEqual(expectedState); }); }); + + describe('SET_IMAGE_DETAILS', () => { + it('should set imageDetails', () => { + const expectedState = { ...mockState, imageDetails: { foo: 'bar' } }; + mutations[types.SET_IMAGE_DETAILS](mockState, { foo: 'bar' }); + + expect(mockState).toEqual(expectedState); + }); + }); }); diff --git a/spec/frontend/registry/explorer/utils_spec.js b/spec/frontend/registry/explorer/utils_spec.js new file mode 100644 index 00000000000..77c14ccee65 --- /dev/null +++ b/spec/frontend/registry/explorer/utils_spec.js @@ -0,0 +1,19 @@ +import { pathGenerator } from '~/registry/explorer/utils'; + +describe('Utils', () => { + describe('pathGenerator', () => { + const imageDetails = { + path: 'foo/bar/baz', + name: 'baz', + id: 1, + }; + + it('returns the fetch url when no ending is passed', () => { + expect(pathGenerator(imageDetails)).toBe('/foo/bar/registry/repository/1/tags?format=json'); + }); + + it('returns the url with an ending when is passed', () => { + expect(pathGenerator(imageDetails, 'foo')).toBe('/foo/bar/registry/repository/1/foo'); + }); + }); +}); |