summaryrefslogtreecommitdiff
path: root/spec/frontend/security_configuration/components/auto_dev_ops_alert_spec.js
blob: 467ae35408c692fd4a122a6c61041d5bcfcb6767 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
import { GlAlert } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue';

const autoDevopsHelpPagePath = '/autoDevopsHelpPagePath';
const autoDevopsPath = '/enableAutoDevopsPath';

describe('AutoDevopsAlert component', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = mount(AutoDevopsAlert, {
      provide: {
        autoDevopsHelpPagePath,
        autoDevopsPath,
      },
    });
  };

  const findAlert = () => wrapper.findComponent(GlAlert);

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

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

  it('contains correct body text', () => {
    expect(wrapper.text()).toContain('Quickly enable all');
  });

  it('renders the link correctly', () => {
    const link = wrapper.find('a');

    expect(link.attributes('href')).toBe(autoDevopsHelpPagePath);
    expect(link.text()).toBe('Auto DevOps');
  });

  it('bubbles up dismiss events from the GlAlert', () => {
    expect(wrapper.emitted('dismiss')).toBe(undefined);

    findAlert().vm.$emit('dismiss');

    expect(wrapper.emitted('dismiss')).toEqual([[]]);
  });

  it('has a button pointing to autoDevopsPath', () => {
    expect(findAlert().props()).toMatchObject({
      primaryButtonText: 'Enable Auto DevOps',
      primaryButtonLink: autoDevopsPath,
    });
  });
});