diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 00:08:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 00:08:57 +0300 |
commit | f46a8dbf1a0999e27dfeddd258096ef97def8d64 (patch) | |
tree | a3604f2164350e0847538e3920475f85e1ee9ff8 /spec/frontend/pages | |
parent | bb915e6375fe65053937c6bf8a7d0771dc9e4713 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pages')
-rw-r--r-- | spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js b/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js index e7ac2576b6f..46d27528443 100644 --- a/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js +++ b/spec/frontend/pages/admin/jobs/components/table/admin_job_table_app_spec.js @@ -1,5 +1,5 @@ -import { GlSkeletonLoader, GlLoadingIcon } from '@gitlab/ui'; -import { shallowMount } from '@vue/test-utils'; +import { GlSkeletonLoader, GlLoadingIcon, GlEmptyState } from '@gitlab/ui'; +import { mount, shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createMockApollo from 'helpers/mock_apollo_helper'; @@ -8,7 +8,11 @@ import JobsTable from '~/jobs/components/table/jobs_table.vue'; import getJobsQuery from '~/pages/admin/jobs/components/table/graphql/queries/get_all_jobs.query.graphql'; import AdminJobsTableApp from '~/pages/admin/jobs/components/table/admin_jobs_table_app.vue'; -import { mockAllJobsResponsePaginated, statuses } from '../../../../../jobs/mock_data'; +import { + mockAllJobsResponsePaginated, + mockJobsResponseEmpty, + statuses, +} from '../../../../../jobs/mock_data'; Vue.use(VueApollo); @@ -16,10 +20,12 @@ describe('Job table app', () => { let wrapper; const successHandler = jest.fn().mockResolvedValue(mockAllJobsResponsePaginated); + const emptyHandler = jest.fn().mockResolvedValue(mockJobsResponseEmpty); const findSkeletonLoader = () => wrapper.findComponent(GlSkeletonLoader); const findLoadingSpinner = () => wrapper.findComponent(GlLoadingIcon); const findTable = () => wrapper.findComponent(JobsTable); + const findEmptyState = () => wrapper.findComponent(GlEmptyState); const createMockApolloProvider = (handler) => { const requestHandlers = [[getJobsQuery, handler]]; @@ -58,4 +64,24 @@ describe('Job table app', () => { expect(findLoadingSpinner().exists()).toBe(false); }); }); + + describe('empty state', () => { + it('should display empty state if there are no jobs and tab scope is null', async () => { + createComponent({ handler: emptyHandler, mountFn: mount }); + + await waitForPromises(); + + expect(findEmptyState().exists()).toBe(true); + expect(findTable().exists()).toBe(false); + }); + + it('should not display empty state if there are jobs and tab scope is not null', async () => { + createComponent({ handler: successHandler, mountFn: mount }); + + await waitForPromises(); + + expect(findEmptyState().exists()).toBe(false); + expect(findTable().exists()).toBe(true); + }); + }); }); |