environment_monitoring_spec.js 1.0 KB
Newer Older
1
import { shallowMount } from '@vue/test-utils';
2
import { GlButton } from '@gitlab/ui';
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
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,
      },
    });
  };

18 19
  const findButtons = () => wrapper.findAll(GlButton);
  const findButtonsByIcon = icon => findButtons().filter(button => button.props('icon') === icon);
20 21 22 23 24 25 26 27 28 29 30 31 32

  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);
33
    expect(findButtonsByIcon('chart').length).toBe(1);
34
    expect(wrapper.attributes('title')).toBe('Monitoring');
35 36 37
    expect(wrapper.attributes('aria-label')).toBe('Monitoring');
  });
});