diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js')
-rw-r--r-- | spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js b/spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js new file mode 100644 index 00000000000..4e65713a680 --- /dev/null +++ b/spec/frontend/add_context_commits_modal/components/review_tab_container_spec.js @@ -0,0 +1,51 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlLoadingIcon } from '@gitlab/ui'; +import ReviewTabContainer from '~/add_context_commits_modal/components/review_tab_container.vue'; +import CommitItem from '~/diffs/components/commit_item.vue'; +import getDiffWithCommit from '../../diffs/mock_data/diff_with_commit'; + +describe('ReviewTabContainer', () => { + let wrapper; + const { commit } = getDiffWithCommit(); + + const createWrapper = (props = {}) => { + wrapper = shallowMount(ReviewTabContainer, { + propsData: { + tab: 'commits', + isLoading: false, + loadingError: false, + loadingFailedText: 'Failed to load commits', + commits: [], + selectedRow: [], + ...props, + }, + }); + }; + + beforeEach(() => { + createWrapper(); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + it('shows loading icon when commits are being loaded', () => { + createWrapper({ isLoading: true }); + expect(wrapper.find(GlLoadingIcon).exists()).toBe(true); + }); + + it('shows loading error text when API call fails', () => { + createWrapper({ loadingError: true }); + expect(wrapper.text()).toContain('Failed to load commits'); + }); + + it('shows "No commits present here" when commits are not present', () => { + expect(wrapper.text()).toContain('No commits present here'); + }); + + it('renders all passed commits as list', () => { + createWrapper({ commits: [commit] }); + expect(wrapper.findAll(CommitItem).length).toBe(1); + }); +}); |