debian-mirror-gitlab/spec/javascripts/serverless/components/function_row_spec.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-05-30 16:15:17 +05:30
import Vue from 'vue';
2019-03-02 22:35:43 +05:30
import functionRowComponent from '~/serverless/components/function_row.vue';
2019-05-30 16:15:17 +05:30
import mountComponent from 'spec/helpers/vue_mount_component_helper';
2019-03-02 22:35:43 +05:30
import { mockServerlessFunction } from '../mock_data';
2019-05-30 16:15:17 +05:30
const createComponent = func => mountComponent(Vue.extend(functionRowComponent), { func });
2019-03-02 22:35:43 +05:30
describe('functionRowComponent', () => {
it('Parses the function details correctly', () => {
const vm = createComponent(mockServerlessFunction);
expect(vm.$el.querySelector('b').innerHTML).toEqual(mockServerlessFunction.name);
expect(vm.$el.querySelector('span').innerHTML).toEqual(mockServerlessFunction.image);
2019-05-30 16:15:17 +05:30
expect(vm.$el.querySelector('time').getAttribute('data-original-title')).not.toBe(null);
expect(vm.$el.querySelector('div.url-text-field').innerHTML).toEqual(
mockServerlessFunction.url,
);
2019-03-02 22:35:43 +05:30
vm.$destroy();
});
it('handles clicks correctly', () => {
const vm = createComponent(mockServerlessFunction);
expect(vm.checkClass(vm.$el.querySelector('p'))).toBe(true); // check somewhere inside the row
2019-05-30 16:15:17 +05:30
expect(vm.checkClass(vm.$el.querySelector('svg'))).toBe(false); // check a button image
expect(vm.checkClass(vm.$el.querySelector('div.url-text-field'))).toBe(false); // check the url bar
2019-03-02 22:35:43 +05:30
vm.$destroy();
});
});