debian-mirror-gitlab/spec/frontend/serverless/components/environment_row_spec.js

69 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-03-09 13:42:32 +05:30
import { shallowMount } from '@vue/test-utils';
2020-01-01 13:55:28 +05:30
import environmentRowComponent from '~/serverless/components/environment_row.vue';
2019-03-02 22:35:43 +05:30
import { mockServerlessFunctions, mockServerlessFunctionsDiffEnv } from '../mock_data';
2019-07-07 11:18:12 +05:30
import { translate } from '~/serverless/utils';
2019-03-02 22:35:43 +05:30
2020-03-09 13:42:32 +05:30
const createComponent = (env, envName) =>
shallowMount(environmentRowComponent, {
propsData: { env, envName },
}).vm;
2019-03-02 22:35:43 +05:30
describe('environment row component', () => {
describe('default global cluster case', () => {
let vm;
beforeEach(() => {
2020-03-09 13:42:32 +05:30
vm = createComponent(translate(mockServerlessFunctions.functions)['*'], '*');
2019-03-02 22:35:43 +05:30
});
2019-07-07 11:18:12 +05:30
afterEach(() => vm.$destroy());
2019-03-02 22:35:43 +05:30
it('has the correct envId', () => {
expect(vm.envId).toEqual('env-global');
});
it('is open by default', () => {
expect(vm.isOpenClass).toEqual({ 'is-open': true });
});
it('generates correct output', () => {
expect(vm.$el.id).toEqual('env-global');
expect(vm.$el.classList.contains('is-open')).toBe(true);
expect(vm.$el.querySelector('div.title').innerHTML.trim()).toEqual('*');
});
it('opens and closes correctly', () => {
expect(vm.isOpen).toBe(true);
vm.toggleOpen();
2019-07-07 11:18:12 +05:30
expect(vm.isOpen).toBe(false);
2019-03-02 22:35:43 +05:30
});
});
describe('default named cluster case', () => {
let vm;
beforeEach(() => {
2020-03-09 13:42:32 +05:30
vm = createComponent(translate(mockServerlessFunctionsDiffEnv.functions).test, 'test');
2019-03-02 22:35:43 +05:30
});
2019-07-07 11:18:12 +05:30
afterEach(() => vm.$destroy());
2019-03-02 22:35:43 +05:30
it('has the correct envId', () => {
expect(vm.envId).toEqual('env-test');
});
it('is open by default', () => {
expect(vm.isOpenClass).toEqual({ 'is-open': true });
});
it('generates correct output', () => {
expect(vm.$el.id).toEqual('env-test');
expect(vm.$el.classList.contains('is-open')).toBe(true);
expect(vm.$el.querySelector('div.title').innerHTML.trim()).toEqual('test');
});
});
});