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

feedback_banner_spec.js « components « subscriptions « jira_connect « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8debfaad5bbde779e8b938434b3f379300f6cb6a (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
import { GlBanner } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import FeedbackBanner from '~/jira_connect/subscriptions/components/feedback_banner.vue';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';

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

  const createComponent = () => {
    wrapper = shallowMount(FeedbackBanner);
  };

  const findBanner = () => wrapper.findComponent(GlBanner);
  const findLocalStorageSync = () => wrapper.findComponent(LocalStorageSync);

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

  it('renders a banner with button', () => {
    expect(findBanner().props()).toMatchObject({
      title: FeedbackBanner.i18n.title,
      buttonText: FeedbackBanner.i18n.buttonText,
      buttonLink: FeedbackBanner.feedbackIssueUrl,
    });
  });

  it('uses localStorage with default value as false', () => {
    expect(findLocalStorageSync().props().value).toBe(false);
  });

  describe('when banner is dimsissed', () => {
    beforeEach(() => {
      findBanner().vm.$emit('close');
    });

    it('hides the banner', () => {
      expect(findBanner().exists()).toBe(false);
    });

    it('updates localStorage value to true', () => {
      expect(findLocalStorageSync().props().value).toBe(true);
    });
  });
});