Commit 75e168c6 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'xanf-vtu-30-wait' into 'master'

Wait for axios mock in spec

Closes #122859

See merge request gitlab-org/gitlab!22285
parents 8bcf5387 4b55afca
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises';
import CustomMetricsFormFields from 'ee/custom_metrics/components/custom_metrics_form_fields.vue'; import CustomMetricsFormFields from 'ee/custom_metrics/components/custom_metrics_form_fields.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -180,11 +181,15 @@ describe('custom metrics form fields component', () => { ...@@ -180,11 +181,15 @@ describe('custom metrics form fields component', () => {
component.vm.$nextTick(() => { component.vm.$nextTick(() => {
expect(component.vm.queryValidateInFlight).toBe(true); expect(component.vm.queryValidateInFlight).toBe(true);
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
waitForPromises()
.then(() => {
component.vm.$nextTick(() => { component.vm.$nextTick(() => {
expect(component.vm.queryValidateInFlight).toBe(false); expect(component.vm.queryValidateInFlight).toBe(false);
expect(component.vm.queryIsValid).toBe(true); expect(component.vm.queryIsValid).toBe(true);
done(); done();
}); });
})
.catch(done.fail);
}); });
}); });
...@@ -205,12 +210,16 @@ describe('custom metrics form fields component', () => { ...@@ -205,12 +210,16 @@ describe('custom metrics form fields component', () => {
queryInput.trigger('input'); queryInput.trigger('input');
component.vm.$nextTick(() => { component.vm.$nextTick(() => {
jest.runOnlyPendingTimers(); jest.runOnlyPendingTimers();
waitForPromises()
.then(() => {
component.vm.$nextTick(() => { component.vm.$nextTick(() => {
expect(component.vm.queryValidateInFlight).toBe(false); expect(component.vm.queryValidateInFlight).toBe(false);
expect(component.vm.queryIsValid).toBe(true); expect(component.vm.queryIsValid).toBe(true);
expect(component.vm.errorMessage).toBe(''); expect(component.vm.errorMessage).toBe('');
done(); done();
}); });
})
.catch(done.fail);
}); });
}); });
}); });
......
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