debian-mirror-gitlab/spec/javascripts/environments/emtpy_state_spec.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Vue from 'vue';
import emptyState from '~/environments/components/empty_state.vue';
2018-03-27 19:54:05 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2018-03-17 18:26:18 +05:30
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-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-new-environment-button').getAttribute('href')).toEqual(
'foo',
);
2018-03-17 18:26:18 +05:30
});
});
describe('Without permission', () => {
beforeEach(() => {
vm = mountComponent(Component, {
newPath: 'foo',
canCreateEnvironment: false,
helpPath: 'bar',
});
});
it('renders empty state without new button', () => {
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
expect(vm.$el.querySelector('.js-new-environment-button')).toBeNull();
2018-03-17 18:26:18 +05:30
});
});
});