Commit c878923a authored by Andrew Fontaine's avatar Andrew Fontaine

Migrate Environments Dropdown to Jest

parent 4239e84c
...@@ -63,38 +63,27 @@ describe('Feature flags > Environments dropdown ', () => { ...@@ -63,38 +63,27 @@ describe('Feature flags > Environments dropdown ', () => {
}); });
describe('with received data', () => { describe('with received data', () => {
it('sets is loading to false', done => { beforeEach(done => setImmediate(() => done()));
setTimeout(() => { it('sets is loading to false', () => {
expect(wrapper.vm.isLoading).toEqual(false); expect(wrapper.vm.isLoading).toEqual(false);
expect(wrapper.find(GlLoadingIcon).exists()).toEqual(false); expect(wrapper.find(GlLoadingIcon).exists()).toEqual(false);
done();
});
}); });
it('sets results with the received data', done => { it('sets results with the received data', () => {
setTimeout(() => {
expect(wrapper.vm.results).toEqual(results); expect(wrapper.vm.results).toEqual(results);
done();
});
}); });
it('sets showSuggestions to true', done => { it('sets showSuggestions to true', () => {
setTimeout(() => {
expect(wrapper.vm.showSuggestions).toEqual(true); expect(wrapper.vm.showSuggestions).toEqual(true);
done();
});
}); });
it('emits even when a suggestion is clicked', done => { it('emits even when a suggestion is clicked', () => {
setTimeout(() => { jest.spyOn(wrapper.vm, '$emit');
spyOn(wrapper.vm, '$emit');
wrapper.find('ul button').trigger('click'); wrapper.find('ul button').trigger('click');
expect(wrapper.vm.$emit).toHaveBeenCalledWith('selectEnvironment', 'production'); expect(wrapper.vm.$emit).toHaveBeenCalledWith('selectEnvironment', 'production');
done();
});
}); });
}); });
}); });
...@@ -115,23 +104,21 @@ describe('Feature flags > Environments dropdown ', () => { ...@@ -115,23 +104,21 @@ describe('Feature flags > Environments dropdown ', () => {
}); });
describe('on click create button', () => { describe('on click create button', () => {
beforeEach(() => { beforeEach(done => {
mock.onGet(`${TEST_HOST}/environments.json'`).replyOnce(200, []); mock.onGet(`${TEST_HOST}/environments.json'`).replyOnce(200, []);
factory(); factory();
wrapper.find('input').setValue('production'); wrapper.find('input').setValue('production');
setImmediate(() => done());
}); });
it('emits create event', done => { it('emits create event', () => {
setTimeout(() => { jest.spyOn(wrapper.vm, '$emit');
spyOn(wrapper.vm, '$emit');
wrapper.find('.js-create-button').trigger('click'); wrapper.find('.js-create-button').trigger('click');
expect(wrapper.vm.$emit).toHaveBeenCalledWith('createClicked', 'production'); expect(wrapper.vm.$emit).toHaveBeenCalledWith('createClicked', 'production');
done();
});
}); });
}); });
}); });
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