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

details_spec.js « wrappers « components « content_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e35b04636f727d52ee3c5d0b297c50f78e999dd0 (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
import { NodeViewContent } from '@tiptap/vue-2';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import DetailsWrapper from '~/content_editor/components/wrappers/details.vue';

describe('content/components/wrappers/details', () => {
  let wrapper;

  const createWrapper = () => {
    wrapper = shallowMountExtended(DetailsWrapper, {
      propsData: {
        node: {},
      },
    });
  };

  it('renders a node-view-content as a ul element', () => {
    createWrapper();

    expect(wrapper.findComponent(NodeViewContent).props().as).toBe('ul');
  });

  it('is "open" by default', () => {
    createWrapper();

    expect(wrapper.findByTestId('details-toggle-icon').classes()).toContain('is-open');
    expect(wrapper.findComponent(NodeViewContent).classes()).toContain('is-open');
  });

  it('closes the details block on clicking the details toggle icon', async () => {
    createWrapper();

    await wrapper.findByTestId('details-toggle-icon').trigger('click');
    expect(wrapper.findByTestId('details-toggle-icon').classes()).not.toContain('is-open');
    expect(wrapper.findComponent(NodeViewContent).classes()).not.toContain('is-open');
  });
});