Commit 7572b7e0 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'upgrade-bootstrap-vue/specs-update-issuable-suggestions' into 'master'

Make issuable suggesstions specs compatible w/ BootstrapVue 2

See merge request gitlab-org/gitlab!20990
parents 1248364b 7ba0274c
...@@ -3,25 +3,31 @@ import App from '~/issuable_suggestions/components/app.vue'; ...@@ -3,25 +3,31 @@ import App from '~/issuable_suggestions/components/app.vue';
import Suggestion from '~/issuable_suggestions/components/item.vue'; import Suggestion from '~/issuable_suggestions/components/item.vue';
describe('Issuable suggestions app component', () => { describe('Issuable suggestions app component', () => {
let vm; let wrapper;
function createComponent(search = 'search') { function createComponent(search = 'search') {
vm = shallowMount(App, { wrapper = shallowMount(App, {
propsData: { propsData: {
search, search,
projectPath: 'project', projectPath: 'project',
}, },
sync: false,
attachToDocument: true,
}); });
} }
beforeEach(() => {
createComponent();
});
afterEach(() => { afterEach(() => {
vm.destroy(); wrapper.destroy();
}); });
it('does not render with empty search', () => { it('does not render with empty search', () => {
createComponent(''); wrapper.setProps({ search: '' });
expect(vm.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
describe('with data', () => { describe('with data', () => {
...@@ -32,65 +38,65 @@ describe('Issuable suggestions app component', () => { ...@@ -32,65 +38,65 @@ describe('Issuable suggestions app component', () => {
}); });
it('renders component', () => { it('renders component', () => {
createComponent(); wrapper.setData(data);
vm.setData(data);
expect(vm.isEmpty()).toBe(false); expect(wrapper.isEmpty()).toBe(false);
}); });
it('does not render with empty search', () => { it('does not render with empty search', () => {
createComponent(''); wrapper.setProps({ search: '' });
vm.setData(data); wrapper.setData(data);
expect(vm.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
it('does not render when loading', () => { it('does not render when loading', () => {
createComponent(); wrapper.setData({
vm.setData({
...data, ...data,
loading: 1, loading: 1,
}); });
expect(vm.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
it('does not render with empty issues data', () => { it('does not render with empty issues data', () => {
createComponent(); wrapper.setData({ issues: [] });
vm.setData({ issues: [] });
expect(vm.isVisible()).toBe(false); expect(wrapper.isVisible()).toBe(false);
}); });
it('renders list of issues', () => { it('renders list of issues', () => {
createComponent(); wrapper.setData(data);
vm.setData(data);
expect(vm.findAll(Suggestion).length).toBe(2); return wrapper.vm.$nextTick(() => {
expect(wrapper.findAll(Suggestion).length).toBe(2);
});
}); });
it('adds margin class to first item', () => { it('adds margin class to first item', () => {
createComponent(); wrapper.setData(data);
vm.setData(data);
return wrapper.vm.$nextTick(() => {
expect( expect(
vm wrapper
.findAll('li') .findAll('li')
.at(0) .at(0)
.is('.append-bottom-default'), .is('.append-bottom-default'),
).toBe(true); ).toBe(true);
});
}); });
it('does not add margin class to last item', () => { it('does not add margin class to last item', () => {
createComponent(); wrapper.setData(data);
vm.setData(data);
return wrapper.vm.$nextTick(() => {
expect( expect(
vm wrapper
.findAll('li') .findAll('li')
.at(1) .at(1)
.is('.append-bottom-default'), .is('.append-bottom-default'),
).toBe(false); ).toBe(false);
});
}); });
}); });
}); });
...@@ -16,6 +16,8 @@ describe('Issuable suggestions suggestion component', () => { ...@@ -16,6 +16,8 @@ describe('Issuable suggestions suggestion component', () => {
...suggestion, ...suggestion,
}, },
}, },
sync: false,
attachToDocument: true,
}); });
} }
......
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