summaryrefslogtreecommitdiff
path: root/spec/frontend/environments/environment_monitoring_spec.js
blob: a73f49f1047d5cb45bb8024806dae457bc048e34 (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
import { shallowMount } from '@vue/test-utils';
import { GlButton } from '@gitlab/ui';
import MonitoringComponent from '~/environments/components/environment_monitoring.vue';

describe('Monitoring Component', () => {
  let wrapper;

  const monitoringUrl = 'https://gitlab.com';

  const createWrapper = () => {
    wrapper = shallowMount(MonitoringComponent, {
      propsData: {
        monitoringUrl,
      },
    });
  };

  const findButtons = () => wrapper.findAll(GlButton);
  const findButtonsByIcon = icon => findButtons().filter(button => button.props('icon') === icon);

  beforeEach(() => {
    createWrapper();
  });

  describe('computed', () => {
    it('title', () => {
      expect(wrapper.vm.title).toBe('Monitoring');
    });
  });

  it('should render a link to environment monitoring page', () => {
    expect(wrapper.attributes('href')).toEqual(monitoringUrl);
    expect(findButtonsByIcon('chart').length).toBe(1);
    expect(wrapper.attributes('title')).toBe('Monitoring');
    expect(wrapper.attributes('aria-label')).toBe('Monitoring');
  });
});