summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/components/filtered_search_bar/tokens/weight_token_spec.js
blob: 4277899f8dbe061e6feb519d2a0e93a527629a70 (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
import { GlFilteredSearchTokenSegment } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
import WeightToken from '~/vue_shared/components/filtered_search_bar/tokens/weight_token.vue';
import { mockWeightToken } from '../mock_data';

jest.mock('~/flash');

describe('WeightToken', () => {
  const weight = '3';
  let wrapper;

  const createComponent = ({ config = mockWeightToken, value = { data: '' } } = {}) =>
    mount(WeightToken, {
      propsData: {
        active: false,
        config,
        value,
      },
      provide: {
        portalName: 'fake target',
        alignSuggestions: function fakeAlignSuggestions() {},
        suggestionsListClass: () => 'custom-class',
      },
    });

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

  it('renders weight value', () => {
    wrapper = createComponent({ value: { data: weight } });

    const tokenSegments = wrapper.findAllComponents(GlFilteredSearchTokenSegment);

    expect(tokenSegments).toHaveLength(3); // `Weight` `=` `3`
    expect(tokenSegments.at(2).text()).toBe(weight);
  });
});