summaryrefslogtreecommitdiff
path: root/spec/javascripts/environments/environment_stop_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/environments/environment_stop_spec.js')
-rw-r--r--spec/javascripts/environments/environment_stop_spec.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/spec/javascripts/environments/environment_stop_spec.js b/spec/javascripts/environments/environment_stop_spec.js
index 5ca65b1debc..8f79b88f3df 100644
--- a/spec/javascripts/environments/environment_stop_spec.js
+++ b/spec/javascripts/environments/environment_stop_spec.js
@@ -1,28 +1,34 @@
-const StopComponent = require('~/environments/components/environment_stop');
+import Vue from 'vue';
+import stopComp from '~/environments/components/environment_stop';
describe('Stop Component', () => {
- preloadFixtures('static/environments/element.html.raw');
-
- let stopURL;
+ let StopComponent;
let component;
+ let spy;
+ const stopURL = '/stop';
beforeEach(() => {
- loadFixtures('static/environments/element.html.raw');
+ StopComponent = Vue.extend(stopComp);
+ spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
+ spyOn(window, 'confirm').and.returnValue(true);
- stopURL = '/stop';
component = new StopComponent({
- el: document.querySelector('.test-dom-element'),
propsData: {
stopUrl: stopURL,
+ service: {
+ postAction: spy,
+ },
},
- });
+ }).$mount();
});
- it('should link to the provided URL', () => {
- expect(component.$el.getAttribute('href')).toEqual(stopURL);
+ it('should render a button to stop the environment', () => {
+ expect(component.$el.tagName).toEqual('BUTTON');
+ expect(component.$el.getAttribute('title')).toEqual('Stop Environment');
});
- it('should have a data-confirm attribute', () => {
- expect(component.$el.getAttribute('data-confirm')).toEqual('Are you sure you want to stop this environment?');
+ it('should call the service when an action is clicked', () => {
+ component.$el.click();
+ expect(spy).toHaveBeenCalled();
});
});