Welcome to mirror list, hosted at ThFree Co, Russian Federation.

function_row_spec.js « components « serverless « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6933a8f6c87e6571bfe236da2bb70187f18bc0cc (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
33
import Vue from 'vue';

import functionRowComponent from '~/serverless/components/function_row.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';

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

const createComponent = func => mountComponent(Vue.extend(functionRowComponent), { func });

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);
    expect(vm.$el.querySelector('time').getAttribute('data-original-title')).not.toBe(null);
    expect(vm.$el.querySelector('div.url-text-field').innerHTML).toEqual(
      mockServerlessFunction.url,
    );

    vm.$destroy();
  });

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

    expect(vm.checkClass(vm.$el.querySelector('p'))).toBe(true); // check somewhere inside the row
    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

    vm.$destroy();
  });
});