diff options
Diffstat (limited to 'spec/frontend/feature_flags/components/edit_feature_flag_spec.js')
-rw-r--r-- | spec/frontend/feature_flags/components/edit_feature_flag_spec.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/spec/frontend/feature_flags/components/edit_feature_flag_spec.js b/spec/frontend/feature_flags/components/edit_feature_flag_spec.js index 799b567a2c0..721b7249abc 100644 --- a/spec/frontend/feature_flags/components/edit_feature_flag_spec.js +++ b/spec/frontend/feature_flags/components/edit_feature_flag_spec.js @@ -4,6 +4,7 @@ import MockAdapter from 'axios-mock-adapter'; import Vue from 'vue'; import Vuex from 'vuex'; import { mockTracking } from 'helpers/tracking_helper'; +import waitForPromises from 'helpers/wait_for_promises'; import { TEST_HOST } from 'spec/test_constants'; import EditFeatureFlag from '~/feature_flags/components/edit_feature_flag.vue'; import Form from '~/feature_flags/components/form.vue'; @@ -20,7 +21,7 @@ describe('Edit feature flag form', () => { endpoint: `${TEST_HOST}/feature_flags.json`, }); - const factory = (provide = {}) => { + const factory = (provide = { searchPath: '/search' }) => { if (wrapper) { wrapper.destroy(); wrapper = null; @@ -31,7 +32,7 @@ describe('Edit feature flag form', () => { }); }; - beforeEach((done) => { + beforeEach(() => { mock = new MockAdapter(axios); mock.onGet(`${TEST_HOST}/feature_flags.json`).replyOnce(200, { id: 21, @@ -45,7 +46,8 @@ describe('Edit feature flag form', () => { destroy_path: '/h5bp/html5-boilerplate/-/feature_flags/21', }); factory(); - setImmediate(() => done()); + + return waitForPromises(); }); afterEach(() => { @@ -60,7 +62,7 @@ describe('Edit feature flag form', () => { }); it('should render the toggle', () => { - expect(wrapper.find(GlToggle).exists()).toBe(true); + expect(wrapper.findComponent(GlToggle).exists()).toBe(true); }); describe('with error', () => { @@ -80,11 +82,11 @@ describe('Edit feature flag form', () => { }); it('should render feature flag form', () => { - expect(wrapper.find(Form).exists()).toEqual(true); + expect(wrapper.findComponent(Form).exists()).toEqual(true); }); it('should track when the toggle is clicked', () => { - const toggle = wrapper.find(GlToggle); + const toggle = wrapper.findComponent(GlToggle); const spy = mockTracking('_category_', toggle.element, jest.spyOn); toggle.trigger('click'); @@ -95,7 +97,7 @@ describe('Edit feature flag form', () => { }); it('should render the toggle with a visually hidden label', () => { - expect(wrapper.find(GlToggle).props()).toMatchObject({ + expect(wrapper.findComponent(GlToggle).props()).toMatchObject({ label: 'Feature flag status', labelPosition: 'hidden', }); |