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

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-10-12 21:52:04 +05:30
import { shallowMount, mount } from '@vue/test-utils';
2020-11-24 15:15:51 +05:30
import { GlButton } from '@gitlab/ui';
2019-07-07 11:18:12 +05:30
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
},
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
},
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',
},
},
});
2020-11-24 15:15:51 +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
});