Commit a83ec8e0 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'replace-callbacks-with-async-await-in-last_commit_spec' into 'master'

Replace callbacks with async/await in last_commit_spec.js

See merge request gitlab-org/gitlab!51929
parents 13682301 2f098e8a
...@@ -58,77 +58,75 @@ describe('Repository last commit component', () => { ...@@ -58,77 +58,75 @@ describe('Repository last commit component', () => {
loading | label loading | label
${true} | ${'shows'} ${true} | ${'shows'}
${false} | ${'hides'} ${false} | ${'hides'}
`('$label when loading icon $loading is true', ({ loading }) => { `('$label when loading icon $loading is true', async ({ loading }) => {
factory(createCommitData(), loading); factory(createCommitData(), loading);
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find(GlLoadingIcon).exists()).toBe(loading);
}); expect(vm.find(GlLoadingIcon).exists()).toBe(loading);
}); });
it('renders commit widget', () => { it('renders commit widget', async () => {
factory(); factory();
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.element).toMatchSnapshot();
}); expect(vm.element).toMatchSnapshot();
}); });
it('renders short commit ID', () => { it('renders short commit ID', async () => {
factory(); factory();
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find('[data-testid="last-commit-id-label"]').text()).toEqual('12345678');
}); expect(vm.find('[data-testid="last-commit-id-label"]').text()).toEqual('12345678');
}); });
it('hides pipeline components when pipeline does not exist', () => { it('hides pipeline components when pipeline does not exist', async () => {
factory(createCommitData({ pipeline: null })); factory(createCommitData({ pipeline: null }));
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find('.js-commit-pipeline').exists()).toBe(false);
}); expect(vm.find('.js-commit-pipeline').exists()).toBe(false);
}); });
it('renders pipeline components', () => { it('renders pipeline components', async () => {
factory(); factory();
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find('.js-commit-pipeline').exists()).toBe(true);
}); expect(vm.find('.js-commit-pipeline').exists()).toBe(true);
}); });
it('hides author component when author does not exist', () => { it('hides author component when author does not exist', async () => {
factory(createCommitData({ author: null })); factory(createCommitData({ author: null }));
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find('.js-user-link').exists()).toBe(false);
expect(vm.find(UserAvatarLink).exists()).toBe(false); expect(vm.find('.js-user-link').exists()).toBe(false);
}); expect(vm.find(UserAvatarLink).exists()).toBe(false);
}); });
it('does not render description expander when description is null', () => { it('does not render description expander when description is null', async () => {
factory(createCommitData({ descriptionHtml: null })); factory(createCommitData({ descriptionHtml: null }));
return vm.vm.$nextTick(() => { await vm.vm.$nextTick();
expect(vm.find('.text-expander').exists()).toBe(false);
expect(vm.find('.commit-row-description').exists()).toBe(false); expect(vm.find('.text-expander').exists()).toBe(false);
}); expect(vm.find('.commit-row-description').exists()).toBe(false);
}); });
it('expands commit description when clicking expander', () => { it('expands commit description when clicking expander', async () => {
factory(createCommitData({ descriptionHtml: 'Test description' })); factory(createCommitData({ descriptionHtml: 'Test description' }));
return vm.vm await vm.vm.$nextTick();
.$nextTick()
.then(() => { vm.find('.text-expander').vm.$emit('click');
vm.find('.text-expander').vm.$emit('click');
return vm.vm.$nextTick(); await vm.vm.$nextTick();
})
.then(() => { expect(vm.find('.commit-row-description').isVisible()).toBe(true);
expect(vm.find('.commit-row-description').isVisible()).toBe(true); expect(vm.find('.text-expander').classes('open')).toBe(true);
expect(vm.find('.text-expander').classes('open')).toBe(true);
});
}); });
it('strips the first newline of the description', async () => { it('strips the first newline of the description', async () => {
...@@ -141,19 +139,19 @@ describe('Repository last commit component', () => { ...@@ -141,19 +139,19 @@ describe('Repository last commit component', () => {
); );
}); });
it('renders the signature HTML as returned by the backend', () => { it('renders the signature HTML as returned by the backend', async () => {
factory(createCommitData({ signatureHtml: '<button>Verified</button>' })); factory(createCommitData({ signatureHtml: '<button>Verified</button>' }));
return vm.vm.$nextTick().then(() => { await vm.vm.$nextTick();
expect(vm.element).toMatchSnapshot();
}); expect(vm.element).toMatchSnapshot();
}); });
it('sets correct CSS class if the commit message is empty', () => { it('sets correct CSS class if the commit message is empty', async () => {
factory(createCommitData({ message: '' })); factory(createCommitData({ message: '' }));
return vm.vm.$nextTick().then(() => { await vm.vm.$nextTick();
expect(vm.find('.item-title').classes()).toContain(emptyMessageClass);
}); expect(vm.find('.item-title').classes()).toContain(emptyMessageClass);
}); });
}); });
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