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

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

  describe('when the request has warnings', () => {
    const 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', () => {
    const wrapper = shallowMount(RequestWarning, {
      propsData: {
        htmlId,
        warnings: [],
      },
    });

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