2017-03-14 00:58:26 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
import stopComp from '~/environments/components/environment_stop';
|
2016-12-29 21:42:48 +00:00
|
|
|
|
2016-11-10 18:58:35 +00:00
|
|
|
describe('Stop Component', () => {
|
2017-03-14 00:58:26 +00:00
|
|
|
let StopComponent;
|
2016-11-19 13:29:48 +00:00
|
|
|
let component;
|
2017-03-14 00:58:26 +00:00
|
|
|
let spy;
|
|
|
|
const stopURL = '/stop';
|
2016-11-19 13:29:48 +00:00
|
|
|
|
2016-11-10 18:58:35 +00:00
|
|
|
beforeEach(() => {
|
2017-03-14 00:58:26 +00:00
|
|
|
StopComponent = Vue.extend(stopComp);
|
|
|
|
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
|
|
|
|
spyOn(window, 'confirm').and.returnValue(true);
|
2016-11-10 18:58:35 +00:00
|
|
|
|
2017-02-09 11:52:22 +00:00
|
|
|
component = new StopComponent({
|
2016-11-10 18:58:35 +00:00
|
|
|
propsData: {
|
2016-12-08 11:54:08 +00:00
|
|
|
stopUrl: stopURL,
|
2017-03-14 00:58:26 +00:00
|
|
|
service: {
|
|
|
|
postAction: spy,
|
|
|
|
},
|
2016-11-10 18:58:35 +00:00
|
|
|
},
|
2017-03-14 00:58:26 +00:00
|
|
|
}).$mount();
|
2016-11-10 18:58:35 +00:00
|
|
|
});
|
2016-11-19 13:07:13 +00:00
|
|
|
|
2017-03-14 00:58:26 +00:00
|
|
|
it('should render a button to stop the environment', () => {
|
|
|
|
expect(component.$el.tagName).toEqual('BUTTON');
|
|
|
|
expect(component.$el.getAttribute('title')).toEqual('Stop Environment');
|
2016-11-19 13:29:48 +00:00
|
|
|
});
|
2016-11-19 13:07:13 +00:00
|
|
|
|
2017-03-14 00:58:26 +00:00
|
|
|
it('should call the service when an action is clicked', () => {
|
|
|
|
component.$el.click();
|
|
|
|
expect(spy).toHaveBeenCalled();
|
2016-11-19 13:07:13 +00:00
|
|
|
});
|
2016-11-10 18:58:35 +00:00
|
|
|
});
|