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

strategy_label_spec.js « components « feature_flags « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c2d5ce10448ed9793fbeae9ba7003b8ad5d8b545 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { mount } from '@vue/test-utils';
import StrategyLabel from '~/feature_flags/components/strategy_label.vue';

const DEFAULT_PROPS = {
  name: 'All Users',
  parameters: 'parameters',
  scopes: 'scope1, scope2',
};

describe('feature_flags/components/feature_flags_tab.vue', () => {
  let wrapper;

  const factory = (props = {}) =>
    mount(
      {
        components: {
          StrategyLabel,
        },
        render(h) {
          return h(StrategyLabel, { props: this.$attrs, on: this.$listeners }, this.$slots.default);
        },
      },
      {
        propsData: {
          ...DEFAULT_PROPS,
          ...props,
        },
      },
    );

  describe('render', () => {
    let strategyLabel;

    beforeEach(() => {
      wrapper = factory({});
      strategyLabel = wrapper.findComponent(StrategyLabel);
    });

    it('should show the strategy label with parameters and scope', () => {
      expect(strategyLabel.text()).toContain(DEFAULT_PROPS.name);
      expect(strategyLabel.text()).toContain(DEFAULT_PROPS.parameters);
      expect(strategyLabel.text()).toContain(DEFAULT_PROPS.scopes);
      expect(strategyLabel.text()).toContain('All Users - parameters: scope1, scope2');
    });
  });

  describe('without parameters', () => {
    let strategyLabel;

    beforeEach(() => {
      wrapper = factory({ parameters: null });
      strategyLabel = wrapper.findComponent(StrategyLabel);
    });

    it('should hide empty params and dash', () => {
      expect(strategyLabel.text()).toContain(DEFAULT_PROPS.name);
      expect(strategyLabel.text()).not.toContain(' - ');
      expect(strategyLabel.text()).toContain('All Users: scope1, scope2');
    });
  });
});