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

embed_dropdown_spec.js « components « snippets « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cb9b9800bfe11a3899a947d8fabe3bf963e926ca (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
import { GlFormInputGroup } from '@gitlab/ui';
import { escape as esc } from 'lodash';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { TEST_HOST } from 'helpers/test_constants';
import EmbedDropdown from '~/snippets/components/embed_dropdown.vue';

const TEST_URL = `${TEST_HOST}/test/no">'xss`;

describe('snippets/components/embed_dropdown', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = shallowMountExtended(EmbedDropdown, {
      propsData: {
        url: TEST_URL,
      },
    });
  };

  const findEmbedSection = () => wrapper.findByTestId('section-Embed');
  const findShareSection = () => wrapper.findByTestId('section-Share');

  it('renders dropdown items', () => {
    createComponent();

    const embedValue = `<script src="${esc(TEST_URL)}.js"></script>`;

    expect(findEmbedSection().text()).toBe('Embed');
    expect(findShareSection().text()).toBe('Share');
    expect(findEmbedSection().findComponent(GlFormInputGroup).attributes('value')).toBe(embedValue);
    expect(findShareSection().findComponent(GlFormInputGroup).attributes('value')).toBe(TEST_URL);
  });
});