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

dropdown_value_spec.js « color_select_dropdown « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 01d3fde279bf4238f33bbb2d12e088608add0426 (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
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();
  });

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

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