2019-07-07 11:18:12 +05:30
|
|
|
import { createLocalVue, 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
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
const createComponent = (localVue, env, envName) =>
|
|
|
|
shallowMount(environmentRowComponent, { localVue, propsData: { env, envName }, sync: false }).vm;
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
describe('environment row component', () => {
|
|
|
|
describe('default global cluster case', () => {
|
2019-07-07 11:18:12 +05:30
|
|
|
let localVue;
|
2019-03-02 22:35:43 +05:30
|
|
|
let vm;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-07-07 11:18:12 +05:30
|
|
|
localVue = createLocalVue();
|
2019-09-04 21:01:54 +05:30
|
|
|
vm = createComponent(localVue, 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;
|
2019-07-07 11:18:12 +05:30
|
|
|
let localVue;
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-07-07 11:18:12 +05:30
|
|
|
localVue = createLocalVue();
|
2019-09-04 21:01:54 +05:30
|
|
|
vm = createComponent(
|
|
|
|
localVue,
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|