debian-mirror-gitlab/spec/frontend/environments/environment_rollback_spec.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-10-12 21:52:04 +05:30
import { shallowMount, mount } from '@vue/test-utils';
2019-07-07 11:18:12 +05:30
import { GlButton } from '@gitlab/ui';
import eventHub from '~/environments/event_hub';
2019-10-12 21:52:04 +05:30
import RollbackComponent from '~/environments/components/environment_rollback.vue';
2017-08-17 22:00:37 +05:30
describe('Rollback Component', () => {
2019-07-07 11:18:12 +05:30
const retryUrl = 'https://gitlab.com/retry';
2017-08-17 22:00:37 +05:30
it('Should render Re-deploy label when isLastDeployment is true', () => {
2019-10-12 21:52:04 +05:30
const wrapper = mount(RollbackComponent, {
2017-08-17 22:00:37 +05:30
propsData: {
2019-07-07 11:18:12 +05:30
retryUrl,
2017-08-17 22:00:37 +05:30
isLastDeployment: true,
2019-07-07 11:18:12 +05:30
environment: {},
2017-08-17 22:00:37 +05:30
},
2020-01-01 13:55:28 +05:30
attachToDocument: true,
sync: false,
2019-10-12 21:52:04 +05:30
});
2017-08-17 22:00:37 +05:30
2019-10-12 21:52:04 +05:30
expect(wrapper.element).toHaveSpriteIcon('repeat');
2017-08-17 22:00:37 +05:30
});
it('Should render Rollback label when isLastDeployment is false', () => {
2019-10-12 21:52:04 +05:30
const wrapper = mount(RollbackComponent, {
2017-08-17 22:00:37 +05:30
propsData: {
2019-07-07 11:18:12 +05:30
retryUrl,
2017-08-17 22:00:37 +05:30
isLastDeployment: false,
2019-07-07 11:18:12 +05:30
environment: {},
2017-08-17 22:00:37 +05:30
},
2020-01-01 13:55:28 +05:30
attachToDocument: true,
sync: false,
2019-10-12 21:52:04 +05:30
});
2017-08-17 22:00:37 +05:30
2019-10-12 21:52:04 +05:30
expect(wrapper.element).toHaveSpriteIcon('redo');
2017-08-17 22:00:37 +05:30
});
2019-07-07 11:18:12 +05:30
it('should emit a "rollback" event on button click', () => {
2019-10-12 21:52:04 +05:30
const eventHubSpy = jest.spyOn(eventHub, '$emit');
const wrapper = shallowMount(RollbackComponent, {
2019-07-07 11:18:12 +05:30
propsData: {
retryUrl,
environment: {
name: 'test',
},
},
});
2019-10-12 21:52:04 +05:30
const button = wrapper.find(GlButton);
2019-07-07 11:18:12 +05:30
button.vm.$emit('click');
expect(eventHubSpy).toHaveBeenCalledWith('requestRollbackEnvironment', {
retryUrl,
isLastDeployment: true,
name: 'test',
});
});
2017-08-17 22:00:37 +05:30
});