summaryrefslogtreecommitdiff
path: root/spec/frontend/content_editor/components/wrappers/label_spec.js
blob: fa32b7461429465e8fbb792889d2eb8e95925b74 (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
import { GlLabel } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import LabelWrapper from '~/content_editor/components/wrappers/label.vue';

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

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

  it("renders a GlLabel with the node's text and color", () => {
    createWrapper({ attrs: { color: '#ff0000', text: 'foo bar', originalText: '~"foo bar"' } });

    const glLabel = wrapper.findComponent(GlLabel);

    expect(glLabel.props()).toMatchObject(
      expect.objectContaining({
        title: 'foo bar',
        backgroundColor: '#ff0000',
      }),
    );
  });

  it('renders a scoped label if there is a "::" in the label', () => {
    createWrapper({ attrs: { color: '#ff0000', text: 'foo::bar', originalText: '~"foo::bar"' } });

    expect(wrapper.findComponent(GlLabel).props().scoped).toBe(true);
  });
});