Commit 8dfbb726 authored by Andrew Fontaine's avatar Andrew Fontaine

Make Edit Feature Flags Form Pass in Jest

Using `setImmediate` instead of `setTimeout` did the trick!
parent c878923a
......@@ -38,7 +38,7 @@ describe('Edit feature flag form', () => {
});
};
beforeEach(() => {
beforeEach(done => {
mock = new MockAdapter(axios);
mock.onGet(`${TEST_HOST}/feature_flags.json'`).replyOnce(200, {
......@@ -63,6 +63,8 @@ describe('Edit feature flag form', () => {
});
factory();
setImmediate(() => done());
});
afterEach(() => {
......@@ -70,17 +72,12 @@ describe('Edit feature flag form', () => {
mock.restore();
});
it('should display the iid', done => {
setTimeout(() => {
it('should display the iid', () => {
expect(wrapper.find('h3').text()).toContain('^5');
done();
});
});
describe('with error', () => {
it('should render the error', done => {
setTimeout(() => {
store.dispatch('edit/receiveUpdateFeatureFlagError', { message: ['The name is required'] });
wrapper.vm.$nextTick(() => {
......@@ -88,23 +85,16 @@ describe('Edit feature flag form', () => {
expect(wrapper.find('.alert-danger').text()).toContain('The name is required');
done();
});
}, 0);
});
});
describe('without error', () => {
it('renders form title', done => {
setTimeout(() => {
it('renders form title', () => {
expect(wrapper.text()).toContain('^5 feature_flag');
done();
}, 0);
});
it('should render feature flag form', done => {
setTimeout(() => {
it('should render feature flag form', () => {
expect(wrapper.find(Form).exists()).toEqual(true);
done();
}, 0);
});
});
});
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