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

62 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2019-05-18 00:54:41 +05:30
import { shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import eventHub from '~/environments/event_hub';
2017-08-17 22:00:37 +05:30
import rollbackComp from '~/environments/components/environment_rollback.vue';
describe('Rollback Component', () => {
2019-05-18 00:54:41 +05:30
const retryUrl = 'https://gitlab.com/retry';
2017-08-17 22:00:37 +05:30
let RollbackComponent;
beforeEach(() => {
RollbackComponent = Vue.extend(rollbackComp);
});
it('Should render Re-deploy label when isLastDeployment is true', () => {
const component = new RollbackComponent({
el: document.querySelector('.test-dom-element'),
propsData: {
2019-05-18 00:54:41 +05:30
retryUrl,
2017-08-17 22:00:37 +05:30
isLastDeployment: true,
2019-05-18 00:54:41 +05:30
environment: {},
2017-08-17 22:00:37 +05:30
},
}).$mount();
2018-11-18 11:00:15 +05:30
expect(component.$el).toHaveSpriteIcon('repeat');
2017-08-17 22:00:37 +05:30
});
it('Should render Rollback label when isLastDeployment is false', () => {
const component = new RollbackComponent({
el: document.querySelector('.test-dom-element'),
propsData: {
2019-05-18 00:54:41 +05:30
retryUrl,
2017-08-17 22:00:37 +05:30
isLastDeployment: false,
2019-05-18 00:54:41 +05:30
environment: {},
2017-08-17 22:00:37 +05:30
},
}).$mount();
2018-11-18 11:00:15 +05:30
expect(component.$el).toHaveSpriteIcon('redo');
2017-08-17 22:00:37 +05:30
});
2019-05-18 00:54:41 +05:30
it('should emit a "rollback" event on button click', () => {
const eventHubSpy = spyOn(eventHub, '$emit');
const component = shallowMount(RollbackComponent, {
propsData: {
retryUrl,
environment: {
name: 'test',
},
},
});
const button = component.find(GlButton);
button.vm.$emit('click');
expect(eventHubSpy).toHaveBeenCalledWith('requestRollbackEnvironment', {
retryUrl,
isLastDeployment: true,
name: 'test',
});
});
2017-08-17 22:00:37 +05:30
});