diff options
Diffstat (limited to 'spec/frontend/environments/folder/environments_folder_view_spec.js')
-rw-r--r-- | spec/frontend/environments/folder/environments_folder_view_spec.js | 50 |
1 files changed, 3 insertions, 47 deletions
diff --git a/spec/frontend/environments/folder/environments_folder_view_spec.js b/spec/frontend/environments/folder/environments_folder_view_spec.js index f8b8465cf6f..23506eb018d 100644 --- a/spec/frontend/environments/folder/environments_folder_view_spec.js +++ b/spec/frontend/environments/folder/environments_folder_view_spec.js @@ -5,6 +5,7 @@ import { removeBreakLine, removeWhitespace } from 'helpers/text_helper'; import EnvironmentTable from '~/environments/components/environments_table.vue'; import EnvironmentsFolderViewComponent from '~/environments/folder/environments_folder_view.vue'; import axios from '~/lib/utils/axios_utils'; +import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { environmentsList } from '../mock_data'; describe('Environments Folder View', () => { @@ -22,7 +23,7 @@ describe('Environments Folder View', () => { const mockEnvironments = (environmentList) => { mock.onGet(mockData.endpoint).reply( - 200, + HTTP_STATUS_OK, { environments: environmentList, stopped_count: 1, @@ -54,7 +55,6 @@ describe('Environments Folder View', () => { afterEach(() => { mock.restore(); - wrapper.destroy(); }); describe('successful request', () => { @@ -95,32 +95,12 @@ describe('Environments Folder View', () => { it('should render pagination', () => { expect(wrapper.findComponent(GlPagination).exists()).toBe(true); }); - - it('should make an API request when changing page', () => { - jest.spyOn(wrapper.vm, 'updateContent').mockImplementation(() => {}); - wrapper.find('.gl-pagination .page-item:nth-last-of-type(2) .page-link').trigger('click'); - expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ - scope: wrapper.vm.scope, - page: '10', - nested: true, - }); - }); - - it('should make an API request when using tabs', () => { - jest.spyOn(wrapper.vm, 'updateContent').mockImplementation(() => {}); - findEnvironmentsTabStopped().trigger('click'); - expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ - scope: 'stopped', - page: '1', - nested: true, - }); - }); }); }); describe('unsuccessfull request', () => { beforeEach(() => { - mock.onGet(mockData.endpoint).reply(500, { environments: [] }); + mock.onGet(mockData.endpoint).reply(HTTP_STATUS_INTERNAL_SERVER_ERROR, { environments: [] }); createWrapper(); return axios.waitForAll(); }); @@ -160,29 +140,5 @@ describe('Environments Folder View', () => { expect(wrapper.vm.requestData.page).toEqual('4'); })); }); - - describe('onChangeTab', () => { - it('should set page to 1', () => { - jest.spyOn(wrapper.vm, 'updateContent').mockImplementation(() => {}); - wrapper.vm.onChangeTab('stopped'); - expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ - scope: 'stopped', - page: '1', - nested: true, - }); - }); - }); - - describe('onChangePage', () => { - it('should update page and keep scope', () => { - jest.spyOn(wrapper.vm, 'updateContent').mockImplementation(() => {}); - wrapper.vm.onChangePage(4); - expect(wrapper.vm.updateContent).toHaveBeenCalledWith({ - scope: wrapper.vm.scope, - page: '4', - nested: true, - }); - }); - }); }); }); |