summaryrefslogtreecommitdiff
path: root/spec/frontend/jira_connect/subscriptions/components/compatibility_alert_spec.js
blob: 5f38a0acb9d227389eb8a39bde373b2b4a52e6d1 (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
import { GlAlert, GlLink } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils';
import CompatibilityAlert from '~/jira_connect/subscriptions/components/compatibility_alert.vue';

import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';

describe('CompatibilityAlert', () => {
  let wrapper;

  const createComponent = ({ mountFn = shallowMount } = {}) => {
    wrapper = mountFn(CompatibilityAlert);
  };

  const findAlert = () => wrapper.findComponent(GlAlert);
  const findLink = () => wrapper.findComponent(GlLink);
  const findLocalStorageSync = () => wrapper.findComponent(LocalStorageSync);

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

  it('displays an alert', () => {
    createComponent();

    expect(findAlert().exists()).toBe(true);
  });

  it('renders help link with target="_blank" and rel="noopener noreferrer"', () => {
    createComponent({ mountFn: mount });
    expect(findLink().attributes()).toMatchObject({
      target: '_blank',
      rel: 'noopener',
    });
  });

  it('`local-storage-sync` value prop is initially false', () => {
    createComponent();

    expect(findLocalStorageSync().props('value')).toBe(false);
  });

  describe('when dismissed', () => {
    beforeEach(async () => {
      createComponent();
      await findAlert().vm.$emit('dismiss');
    });

    it('hides alert', () => {
      expect(findAlert().exists()).toBe(false);
    });

    it('updates value prop of `local-storage-sync`', () => {
      expect(findLocalStorageSync().props('value')).toBe(true);
    });
  });
});