summaryrefslogtreecommitdiff
path: root/spec/frontend/serverless/components/function_row_spec.js
blob: 979f98c4832dc4f3d9197f7eef1dc52271c69407 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import functionRowComponent from '~/serverless/components/function_row.vue';
import { shallowMount } from '@vue/test-utils';
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';

import { mockServerlessFunction } from '../mock_data';

describe('functionRowComponent', () => {
  let wrapper;

  const createComponent = func => {
    wrapper = shallowMount(functionRowComponent, { propsData: { func }, sync: false });
  };

  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);
  });

  it('handles clicks correctly', () => {
    createComponent(mockServerlessFunction);
    const { vm } = wrapper;

    expect(vm.checkClass(vm.$el.querySelector('p'))).toBe(true); // check somewhere inside the row
  });
});