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