2016-11-10 13:58:35 -05:00
|
|
|
//= require vue
|
|
|
|
//= require environments/components/environment_actions
|
|
|
|
|
|
|
|
describe('Actions Component', () => {
|
2016-12-30 19:14:33 -05:00
|
|
|
preloadFixtures('static/environments/element.html.raw');
|
2016-11-10 13:58:35 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2016-12-30 19:14:33 -05:00
|
|
|
loadFixtures('static/environments/element.html.raw');
|
2016-11-10 13:58:35 -05:00
|
|
|
});
|
|
|
|
|
2016-12-08 07:06:49 -05:00
|
|
|
it('should render a dropdown with the provided actions', () => {
|
2016-11-10 13:58:35 -05:00
|
|
|
const actionsMock = [
|
|
|
|
{
|
|
|
|
name: 'bar',
|
2016-11-18 14:40:47 -05:00
|
|
|
play_path: 'https://gitlab.com/play',
|
2016-11-10 13:58:35 -05:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'foo',
|
2016-11-18 14:40:47 -05:00
|
|
|
play_path: '#',
|
2016-11-10 13:58:35 -05:00
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const component = new window.gl.environmentsList.ActionsComponent({
|
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
|
|
|
actions: actionsMock,
|
2016-12-08 07:06:49 -05:00
|
|
|
playIconSvg: '<svg></svg>',
|
2016-11-10 13:58:35 -05:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
2016-11-14 17:37:13 -05:00
|
|
|
component.$el.querySelectorAll('.dropdown-menu li').length,
|
2016-11-10 13:58:35 -05:00
|
|
|
).toEqual(actionsMock.length);
|
|
|
|
expect(
|
2016-11-14 17:37:13 -05:00
|
|
|
component.$el.querySelector('.dropdown-menu li a').getAttribute('href'),
|
2016-11-18 14:40:47 -05:00
|
|
|
).toEqual(actionsMock[0].play_path);
|
2016-11-10 13:58:35 -05:00
|
|
|
});
|
2016-12-08 07:06:49 -05:00
|
|
|
|
|
|
|
it('should render a dropdown with the provided svg', () => {
|
|
|
|
const actionsMock = [
|
|
|
|
{
|
|
|
|
name: 'bar',
|
|
|
|
play_path: 'https://gitlab.com/play',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'foo',
|
|
|
|
play_path: '#',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const component = new window.gl.environmentsList.ActionsComponent({
|
|
|
|
el: document.querySelector('.test-dom-element'),
|
|
|
|
propsData: {
|
|
|
|
actions: actionsMock,
|
|
|
|
playIconSvg: '<svg></svg>',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.js-dropdown-play-icon-container').children,
|
|
|
|
).toContain('svg');
|
|
|
|
|
|
|
|
expect(
|
|
|
|
component.$el.querySelector('.js-action-play-icon-container').children,
|
|
|
|
).toContain('svg');
|
|
|
|
});
|
2016-11-10 13:58:35 -05:00
|
|
|
});
|