gitlab-org--gitlab-foss/spec/javascripts/environments/environment_actions_spec.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
import actionsComp from '~/environments/components/environment_actions';
describe('Actions Component', () => {
let ActionsComponent;
let actionsMock;
let spy;
let component;
beforeEach(() => {
ActionsComponent = Vue.extend(actionsComp);
actionsMock = [
{
name: 'bar',
2016-11-18 14:40:47 -05:00
play_path: 'https://gitlab.com/play',
},
{
name: 'foo',
2016-11-18 14:40:47 -05:00
play_path: '#',
},
];
spy = jasmine.createSpy('spy').and.returnValue(Promise.resolve());
component = new ActionsComponent({
propsData: {
actions: actionsMock,
service: {
postAction: spy,
},
},
}).$mount();
});
it('should render a dropdown with the provided actions', () => {
expect(
component.$el.querySelectorAll('.dropdown-menu li').length,
).toEqual(actionsMock.length);
});
it('should call the service when an action is clicked', () => {
component.$el.querySelector('.dropdown').click();
component.$el.querySelector('.js-manual-action-link').click();
expect(spy).toHaveBeenCalledWith(actionsMock[0].play_path);
});
});