summaryrefslogtreecommitdiff
path: root/spec/frontend/performance_bar/components/request_warning_spec.js
blob: 9dd8ea9f93390db71d31b3ba39b5435fef2358d5 (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
42
import { shallowMount } from '@vue/test-utils';
import RequestWarning from '~/performance_bar/components/request_warning.vue';

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

  afterEach(() => {
    wrapper.destroy();
  });

  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[id]').attributes('id')).toEqual(htmlId);
      expect(wrapper.find('span[id] gl-emoji').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('');
    });
  });
});