Migrate feature flags table specs to Jest

Migrated feature_flags_table_spec.js from Karma to Jest
parent 57f016b4
import featureFlagsTableComponent from 'ee/feature_flags/components/feature_flags_table.vue'; import FeatureFlagsTable from 'ee/feature_flags/components/feature_flags_table.vue';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { trimText } from 'spec/helpers/text_helper'; import { trimText } from 'helpers/text_helper';
import { import {
ROLLOUT_STRATEGY_ALL_USERS, ROLLOUT_STRATEGY_ALL_USERS,
ROLLOUT_STRATEGY_PERCENT_ROLLOUT, ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
...@@ -10,21 +10,26 @@ import { ...@@ -10,21 +10,26 @@ import {
const localVue = createLocalVue(); const localVue = createLocalVue();
describe('Feature flag table', () => { describe('Feature flag table', () => {
let Component;
let wrapper; let wrapper;
const createWrapper = (propsData, opts = {}) => {
wrapper = shallowMount(FeatureFlagsTable, {
propsData,
sync: false,
localVue,
...opts,
});
};
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
describe('with an active scope and a standard rollout strategy', () => { describe('with an active scope and a standard rollout strategy', () => {
beforeEach(() => { beforeEach(() => {
Component = localVue.extend(featureFlagsTableComponent); createWrapper(
{
wrapper = shallowMount(Component, {
localVue,
provide: { glFeatures: { featureFlagIID: true } },
propsData: {
featureFlags: [ featureFlags: [
{ {
id: 1, id: 1,
...@@ -50,7 +55,10 @@ describe('Feature flag table', () => { ...@@ -50,7 +55,10 @@ describe('Feature flag table', () => {
], ],
csrfToken: 'fakeToken', csrfToken: 'fakeToken',
}, },
}); {
provide: { glFeatures: { featureFlagIID: true } },
},
);
}); });
it('Should render a table', () => { it('Should render a table', () => {
...@@ -103,35 +111,30 @@ describe('Feature flag table', () => { ...@@ -103,35 +111,30 @@ describe('Feature flag table', () => {
describe('with an active scope and a percentage rollout strategy', () => { describe('with an active scope and a percentage rollout strategy', () => {
beforeEach(() => { beforeEach(() => {
Component = localVue.extend(featureFlagsTableComponent); createWrapper({
featureFlags: [
wrapper = shallowMount(Component, { {
localVue, id: 1,
propsData: { active: true,
featureFlags: [ name: 'flag name',
{ description: 'flag description',
id: 1, destroy_path: 'destroy/path',
active: true, edit_path: 'edit/path',
name: 'flag name', scopes: [
description: 'flag description', {
destroy_path: 'destroy/path', id: 1,
edit_path: 'edit/path', active: true,
scopes: [ environmentScope: 'scope',
{ canUpdate: true,
id: 1, protected: false,
active: true, rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
environmentScope: 'scope', rolloutPercentage: '54',
canUpdate: true, shouldBeDestroyed: false,
protected: false, },
rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, ],
rolloutPercentage: '54', },
shouldBeDestroyed: false, ],
}, csrfToken: 'fakeToken',
],
},
],
csrfToken: 'fakeToken',
},
}); });
}); });
...@@ -144,35 +147,30 @@ describe('Feature flag table', () => { ...@@ -144,35 +147,30 @@ describe('Feature flag table', () => {
describe('with an inactive scope', () => { describe('with an inactive scope', () => {
beforeEach(() => { beforeEach(() => {
Component = localVue.extend(featureFlagsTableComponent); createWrapper({
featureFlags: [
wrapper = shallowMount(Component, { {
localVue, id: 1,
propsData: { active: true,
featureFlags: [ name: 'flag name',
{ description: 'flag description',
id: 1, destroy_path: 'destroy/path',
active: true, edit_path: 'edit/path',
name: 'flag name', scopes: [
description: 'flag description', {
destroy_path: 'destroy/path', id: 1,
edit_path: 'edit/path', active: false,
scopes: [ environmentScope: 'scope',
{ canUpdate: true,
id: 1, protected: false,
active: false, rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS,
environmentScope: 'scope', rolloutPercentage: DEFAULT_PERCENT_ROLLOUT,
canUpdate: true, shouldBeDestroyed: false,
protected: false, },
rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, ],
rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, },
shouldBeDestroyed: false, ],
}, csrfToken: 'fakeToken',
],
},
],
csrfToken: 'fakeToken',
},
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment