2017-11-23 07:04:03 -05:00
|
|
|
import Vue from 'vue';
|
|
|
|
import emptyState from '~/environments/components/empty_state.vue';
|
2018-02-26 14:43:34 -05:00
|
|
|
import mountComponent from 'spec/helpers/vue_mount_component_helper';
|
2017-11-23 07:04:03 -05:00
|
|
|
|
|
|
|
describe('environments empty state', () => {
|
|
|
|
let vm;
|
|
|
|
let Component;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
Component = Vue.extend(emptyState);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('With permissions', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
newPath: 'foo',
|
|
|
|
canCreateEnvironment: true,
|
|
|
|
helpPath: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders empty state and new environment button', () => {
|
2018-10-30 16:28:31 -04:00
|
|
|
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
|
|
|
|
"You don't have any environments right now",
|
|
|
|
);
|
2017-11-23 07:04:03 -05:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
expect(vm.$el.querySelector('.js-new-environment-button').getAttribute('href')).toEqual(
|
|
|
|
'foo',
|
|
|
|
);
|
2017-11-23 07:04:03 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Without permission', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
vm = mountComponent(Component, {
|
|
|
|
newPath: 'foo',
|
|
|
|
canCreateEnvironment: false,
|
|
|
|
helpPath: 'bar',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders empty state without new button', () => {
|
2018-10-30 16:28:31 -04:00
|
|
|
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
|
|
|
|
"You don't have any environments right now",
|
|
|
|
);
|
2017-11-23 07:04:03 -05:00
|
|
|
|
2018-10-30 16:28:31 -04:00
|
|
|
expect(vm.$el.querySelector('.js-new-environment-button')).toBeNull();
|
2017-11-23 07:04:03 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|