Commit 29c908a4 authored by Emily Ring's avatar Emily Ring Committed by Clement Ho

Updated emtpy_state_spec.js test for jest

Moved file to spec/frontend/environments/ folder.
Modified tests to migrate from karma testing, to jest testing.
parent a796a807
import { shallowMount } from '@vue/test-utils';
import EmptyState from '~/environments/components/empty_state.vue';
describe('environments empty state', () => {
let vm;
beforeEach(() => {
vm = shallowMount(EmptyState, {
propsData: {
newPath: 'foo',
canCreateEnvironment: true,
helpPath: 'bar',
},
});
});
afterEach(() => {
vm.destroy();
});
it('renders the empty state', () => {
expect(vm.find('.js-blank-state-title').text()).toEqual(
"You don't have any environments right now",
);
});
it('renders the new environment button', () => {
expect(vm.find('.js-new-environment-button').attributes('href')).toEqual('foo');
});
describe('without permission', () => {
beforeEach(() => {
vm.setProps({ canCreateEnvironment: false });
});
it('does not render the new environment button', () => {
expect(vm.find('.js-new-environment-button').exists()).toBe(false);
});
});
});
import Vue from 'vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import emptyState from '~/environments/components/empty_state.vue';
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', () => {
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
expect(vm.$el.querySelector('.js-new-environment-button').getAttribute('href')).toEqual(
'foo',
);
});
});
describe('Without permission', () => {
beforeEach(() => {
vm = mountComponent(Component, {
newPath: 'foo',
canCreateEnvironment: false,
helpPath: 'bar',
});
});
it('renders empty state without new button', () => {
expect(vm.$el.querySelector('.js-blank-state-title').textContent.trim()).toEqual(
"You don't have any environments right now",
);
expect(vm.$el.querySelector('.js-new-environment-button')).toBeNull();
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment