1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
import Vue from 'vue';
import rollbackComp from '~/environments/components/environment_rollback';
describe('Rollback Component', () => {
const retryURL = 'https://gitlab.com/retry';
let RollbackComponent;
let spy;
beforeEach(() => {
RollbackComponent = Vue.extend(rollbackComp);
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
});
it('Should render Re-deploy label when isLastDeployment is true', () => {
const component = new RollbackComponent({
el: document.querySelector('.test-dom-element'),
propsData: {
retryUrl: retryURL,
isLastDeployment: true,
service: {
postAction: spy,
},
},
}).$mount();
expect(component.$el.querySelector('span').textContent).toContain('Re-deploy');
});
it('Should render Rollback label when isLastDeployment is false', () => {
const component = new RollbackComponent({
el: document.querySelector('.test-dom-element'),
propsData: {
retryUrl: retryURL,
isLastDeployment: false,
service: {
postAction: spy,
},
},
}).$mount();
expect(component.$el.querySelector('span').textContent).toContain('Rollback');
});
it('should call the service when the button is clicked', () => {
const component = new RollbackComponent({
propsData: {
retryUrl: retryURL,
isLastDeployment: false,
service: {
postAction: spy,
},
},
}).$mount();
component.$el.click();
expect(spy).toHaveBeenCalledWith(retryURL);
});
});
|