Welcome to mirror list, hosted at ThFree Co, Russian Federation.

upgrade_banner_spec.js « components « security_configuration « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a35fded72fb80b745c97a1ddda90cdb103cd2484 (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
56
57
58
59
60
import { GlBanner } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import UpgradeBanner from '~/security_configuration/components/upgrade_banner.vue';

const upgradePath = '/upgrade';

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

  const createComponent = (propsData) => {
    closeSpy = jest.fn();

    wrapper = shallowMountExtended(UpgradeBanner, {
      provide: {
        upgradePath,
      },
      propsData,
      listeners: {
        close: closeSpy,
      },
    });
  };

  const findGlBanner = () => wrapper.findComponent(GlBanner);

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

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

  it('passes the expected props to GlBanner', () => {
    expect(findGlBanner().props()).toMatchObject({
      title: UpgradeBanner.i18n.title,
      buttonText: UpgradeBanner.i18n.buttonText,
      buttonLink: upgradePath,
    });
  });

  it('renders the list of benefits', () => {
    const wrapperText = wrapper.text();

    expect(wrapperText).toContain('Immediately begin risk analysis and remediation');
    expect(wrapperText).toContain('statistics in the merge request');
    expect(wrapperText).toContain('statistics across projects');
    expect(wrapperText).toContain('Runtime security metrics');
    expect(wrapperText).toContain('More scan types, including Container Scanning,');
  });

  it(`re-emits GlBanner's close event`, () => {
    expect(closeSpy).not.toHaveBeenCalled();

    wrapper.findComponent(GlBanner).vm.$emit('close');

    expect(closeSpy).toHaveBeenCalledTimes(1);
  });
});