blob: fe614f031192b86043fabe96a60a85c4824d14db (
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
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { hexToRgb } from '~/lib/utils/color_utils';
import ColorItem from '~/vue_shared/components/color_select_dropdown/color_item.vue';
import { color } from './mock_data';
describe('ColorItem', () => {
let wrapper;
const propsData = color;
const createComponent = () => {
wrapper = shallowMountExtended(ColorItem, {
propsData,
});
};
const findColorItem = () => wrapper.findByTestId('color-item');
beforeEach(() => {
createComponent();
});
afterEach(() => {
wrapper.destroy();
});
it('renders the correct title', () => {
expect(wrapper.text()).toBe(propsData.title);
});
it('renders the correct background color for the color item', () => {
const convertedColor = hexToRgb(propsData.color).join(', ');
expect(findColorItem().attributes('style')).toBe(`background-color: rgb(${convertedColor});`);
});
});
|