summaryrefslogtreecommitdiff
path: root/spec/frontend/vue_shared/gl_feature_flags_plugin_spec.js
blob: 6ecc330b5af88f3f021b471218547dd639af5bf0 (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
import { createLocalVue, shallowMount } from '@vue/test-utils';
import GlFeatureFlags from '~/vue_shared/gl_feature_flags_plugin';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';

const localVue = createLocalVue();

describe('GitLab Feature Flags Plugin', () => {
  beforeEach(() => {
    window.gon = {
      features: {
        aFeature: true,
        bFeature: false,
      },
    };

    localVue.use(GlFeatureFlags);
  });

  it('should provide glFeatures to components', () => {
    const component = {
      template: `<span></span>`,
      inject: ['glFeatures'],
    };
    const wrapper = shallowMount(component, { localVue });
    expect(wrapper.vm.glFeatures).toEqual({
      aFeature: true,
      bFeature: false,
    });
  });

  it('should integrate with the glFeatureMixin', () => {
    const component = {
      template: `<span></span>`,
      mixins: [glFeatureFlagsMixin()],
    };
    const wrapper = shallowMount(component, { localVue });
    expect(wrapper.vm.glFeatures).toEqual({
      aFeature: true,
      bFeature: false,
    });
  });
});