diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:08:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:08:20 +0300 |
commit | d80f3cd75e700b6e62910865bfd36734644ffa89 (patch) | |
tree | aa2fa2f2b4385854c13591bef8e74924ef661657 /spec/frontend/releases/components/app_show_spec.js | |
parent | be81c1578d65f25edfde8aa550f190b8d3e6d976 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/releases/components/app_show_spec.js')
-rw-r--r-- | spec/frontend/releases/components/app_show_spec.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/frontend/releases/components/app_show_spec.js b/spec/frontend/releases/components/app_show_spec.js new file mode 100644 index 00000000000..3dc9964c25c --- /dev/null +++ b/spec/frontend/releases/components/app_show_spec.js @@ -0,0 +1,61 @@ +import Vuex from 'vuex'; +import { shallowMount } from '@vue/test-utils'; +import ReleaseShowApp from '~/releases/components/app_show.vue'; +import { release as originalRelease } from '../mock_data'; +import { GlSkeletonLoading } from '@gitlab/ui'; +import ReleaseBlock from '~/releases/components/release_block.vue'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; + +describe('Release show component', () => { + let wrapper; + let release; + let actions; + + beforeEach(() => { + release = convertObjectPropsToCamelCase(originalRelease); + }); + + const factory = state => { + actions = { + fetchRelease: jest.fn(), + }; + + const store = new Vuex.Store({ + modules: { + detail: { + namespaced: true, + actions, + state, + }, + }, + }); + + wrapper = shallowMount(ReleaseShowApp, { store }); + }; + + const findLoadingSkeleton = () => wrapper.find(GlSkeletonLoading); + const findReleaseBlock = () => wrapper.find(ReleaseBlock); + + it('calls fetchRelease when the component is created', () => { + factory({ release }); + expect(actions.fetchRelease).toHaveBeenCalledTimes(1); + }); + + it('shows a loading skeleton and hides the release block while the API call is in progress', () => { + factory({ isFetchingRelease: true }); + expect(findLoadingSkeleton().exists()).toBe(true); + expect(findReleaseBlock().exists()).toBe(false); + }); + + it('hides the loading skeleton and shows the release block when the API call finishes successfully', () => { + factory({ isFetchingRelease: false }); + expect(findLoadingSkeleton().exists()).toBe(false); + expect(findReleaseBlock().exists()).toBe(true); + }); + + it('hides both the loading skeleton and the release block when the API call fails', () => { + factory({ fetchError: new Error('Uh oh') }); + expect(findLoadingSkeleton().exists()).toBe(false); + expect(findReleaseBlock().exists()).toBe(false); + }); +}); |