2022-01-26 12:08:38 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
2019-12-21 20:55:43 +05:30
|
|
|
import GlFeatureFlags from '~/vue_shared/gl_feature_flags_plugin';
|
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
|
|
|
|
|
|
|
describe('GitLab Feature Flags Plugin', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
window.gon = {
|
|
|
|
features: {
|
|
|
|
aFeature: true,
|
|
|
|
bFeature: false,
|
|
|
|
},
|
2021-04-17 20:07:23 +05:30
|
|
|
licensed_features: {
|
|
|
|
cFeature: true,
|
|
|
|
dFeature: false,
|
|
|
|
},
|
2019-12-21 20:55:43 +05:30
|
|
|
};
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
Vue.use(GlFeatureFlags);
|
2019-12-21 20:55:43 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('should provide glFeatures to components', () => {
|
|
|
|
const component = {
|
|
|
|
template: `<span></span>`,
|
|
|
|
inject: ['glFeatures'],
|
|
|
|
};
|
2022-01-26 12:08:38 +05:30
|
|
|
const wrapper = shallowMount(component);
|
2019-12-21 20:55:43 +05:30
|
|
|
expect(wrapper.vm.glFeatures).toEqual({
|
|
|
|
aFeature: true,
|
|
|
|
bFeature: false,
|
2021-04-17 20:07:23 +05:30
|
|
|
cFeature: true,
|
|
|
|
dFeature: false,
|
2019-12-21 20:55:43 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should integrate with the glFeatureMixin', () => {
|
|
|
|
const component = {
|
|
|
|
template: `<span></span>`,
|
|
|
|
mixins: [glFeatureFlagsMixin()],
|
|
|
|
};
|
2022-01-26 12:08:38 +05:30
|
|
|
const wrapper = shallowMount(component);
|
2019-12-21 20:55:43 +05:30
|
|
|
expect(wrapper.vm.glFeatures).toEqual({
|
|
|
|
aFeature: true,
|
|
|
|
bFeature: false,
|
2021-04-17 20:07:23 +05:30
|
|
|
cFeature: true,
|
|
|
|
dFeature: false,
|
2019-12-21 20:55:43 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|