Commit c7698d9d authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '194276-environments_folder_view_spec' into 'master'

Migrate ee/spec/javascripts/environments/environments_folder_view_spec.js to jest test

See merge request gitlab-org/gitlab!25052
parents dd3b2209 7d0a0fe4
import Vue from 'vue';
import MockAdapter from 'axios-mock-adapter';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import { environmentsList } from 'spec/environments/mock_data';
import { mount } from '@vue/test-utils';
import axios from '~/lib/utils/axios_utils';
import environmentsFolderViewComponent from '~/environments/folder/environments_folder_view.vue';
import MockAdapter from 'axios-mock-adapter';
import { environmentsList } from './mock_data';
import EnvironmentsFolderViewComponent from '~/environments/folder/environments_folder_view.vue';
describe('Environments Folder View', () => {
let Component;
let component;
let mock;
let wrapper;
const mockData = {
endpoint: 'environments.json',
......@@ -24,14 +22,11 @@ describe('Environments Folder View', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
Component = Vue.extend(environmentsFolderViewComponent);
});
afterEach(() => {
mock.restore();
component.$destroy();
wrapper.destroy();
});
describe('successful request', () => {
......@@ -53,15 +48,13 @@ describe('Environments Folder View', () => {
},
);
component = mountComponent(Component, mockData);
wrapper = mount(EnvironmentsFolderViewComponent, { propsData: mockData });
return axios.waitForAll();
});
describe('deploy boards', () => {
it('should render arrow to open deploy boards', done => {
setTimeout(() => {
expect(component.$el.querySelector('.folder-icon.ic-chevron-right')).not.toBeNull();
done();
}, 0);
it('should render arrow to open deploy boards', () => {
expect(wrapper.find('.folder-icon.ic-chevron-right').exists()).toBe(true);
});
});
});
......
......@@ -100,3 +100,35 @@ export const environment = {
created_at: '2016-11-07T11:11:16.525Z',
updated_at: '2016-11-10T15:55:58.778Z',
};
const sharedEnvironmentData = id => ({
environment_path: `/root/review-app/environments/${id}`,
external_url: null,
folderName: 'build',
has_stop_action: false,
id,
last_deployment: null,
project_path: '/root/review-app',
rollout_status: {},
state: 'available',
stop_path: `/root/review-app/environments/${id}/stop`,
});
export const environmentsList = [
{
name: 'DEV',
size: 1,
environment_type: null,
created_at: '2017-01-31T10:53:46.894Z',
updated_at: '2017-01-31T10:53:46.894Z',
...sharedEnvironmentData(7),
},
{
name: 'build/update-README',
size: 5,
environment_type: 'build',
created_at: '2017-02-01T19:42:18.400Z',
updated_at: '2017-02-01T19:42:18.400Z',
...sharedEnvironmentData(12),
},
];
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment