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

33 lines
1 KiB
JavaScript
Raw Normal View History

2019-03-02 22:35:43 +05:30
import functionRowComponent from '~/serverless/components/function_row.vue';
2019-07-07 11:18:12 +05:30
import { shallowMount } from '@vue/test-utils';
2019-09-04 21:01:54 +05:30
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
2019-03-02 22:35:43 +05:30
import { mockServerlessFunction } from '../mock_data';
describe('functionRowComponent', () => {
2019-09-04 21:01:54 +05:30
let wrapper;
2019-03-02 22:35:43 +05:30
2019-09-04 21:01:54 +05:30
const createComponent = func => {
wrapper = shallowMount(functionRowComponent, { propsData: { func }, sync: false });
};
2019-03-02 22:35:43 +05:30
2019-09-04 21:01:54 +05:30
afterEach(() => {
wrapper.destroy();
});
it('Parses the function details correctly', () => {
createComponent(mockServerlessFunction);
expect(wrapper.find('b').text()).toBe(mockServerlessFunction.name);
expect(wrapper.find('span').text()).toBe(mockServerlessFunction.image);
expect(wrapper.find(Timeago).attributes('time')).not.toBe(null);
2019-03-02 22:35:43 +05:30
});
it('handles clicks correctly', () => {
2019-09-04 21:01:54 +05:30
createComponent(mockServerlessFunction);
const { vm } = wrapper;
2019-03-02 22:35:43 +05:30
expect(vm.checkClass(vm.$el.querySelector('p'))).toBe(true); // check somewhere inside the row
});
});