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

request_warning_spec.js « components « performance_bar « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a4f0d388e33890e0808357498d957950f826ca87 (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
34
35
36
37
38
39
40
41
import Vue from 'vue';
import { shallowMount } from '@vue/test-utils';
import RequestWarning from '~/performance_bar/components/request_warning.vue';

Vue.config.ignoredElements = ['gl-emoji'];

describe('request warning', () => {
  let wrapper;
  const htmlId = 'request-123';

  describe('when the request has warnings', () => {
    beforeEach(() => {
      wrapper = shallowMount(RequestWarning, {
        propsData: {
          htmlId,
          warnings: ['gitaly calls: 30 over 10', 'gitaly duration: 1500 over 1000'],
        },
      });
    });

    it('adds a warning emoji with the correct ID', () => {
      expect(wrapper.find('span gl-emoji[id]').attributes('id')).toEqual(htmlId);
      expect(wrapper.find('span gl-emoji[id]').element.dataset.name).toEqual('warning');
    });
  });

  describe('when the request does not have warnings', () => {
    beforeEach(() => {
      wrapper = shallowMount(RequestWarning, {
        propsData: {
          htmlId,
          warnings: [],
        },
      });
    });

    it('does nothing', () => {
      expect(wrapper.html()).toBe('');
    });
  });
});