summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/color_select_dropdown/dropdown_value_spec.js
blob: f22592dd604bbbd8877e79f653de33308862d5c9 (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
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';

import ColorItem from '~/vue_shared/components/color_select_dropdown/color_item.vue';
import DropdownValue from '~/vue_shared/components/color_select_dropdown/dropdown_value.vue';

import { color } from './mock_data';

const propsData = {
  selectedColor: color,
};

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

  const findColorItems = () => wrapper.findAllComponents(ColorItem);

  const createComponent = () => {
    wrapper = shallowMountExtended(DropdownValue, { propsData });
  };

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

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

  describe('when there is a color set', () => {
    it('renders the color', () => {
      expect(findColorItems()).toHaveLength(2);
    });

    it.each`
      index | cssClass
      ${0}  | ${['gl-font-base', 'gl-line-height-24']}
      ${1}  | ${['hide-collapsed']}
    `(
      'passes correct props to the ColorItem with CSS class `$cssClass`',
      async ({ index, cssClass }) => {
        expect(findColorItems().at(index).props()).toMatchObject(propsData.selectedColor);
        expect(findColorItems().at(index).classes()).toEqual(cssClass);
      },
    );
  });
});