2019-12-13 13:08:06 -05:00
|
|
|
import SnippetApp from '~/snippets/components/app.vue';
|
2019-12-17 13:07:48 -05:00
|
|
|
import SnippetHeader from '~/snippets/components/snippet_header.vue';
|
2020-01-31 10:08:42 -05:00
|
|
|
import SnippetTitle from '~/snippets/components/snippet_title.vue';
|
|
|
|
import SnippetBlob from '~/snippets/components/snippet_blob_view.vue';
|
2019-12-17 13:07:48 -05:00
|
|
|
import { GlLoadingIcon } from '@gitlab/ui';
|
|
|
|
|
2020-01-08 10:08:01 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2019-12-13 13:08:06 -05:00
|
|
|
|
|
|
|
describe('Snippet view app', () => {
|
|
|
|
let wrapper;
|
|
|
|
const defaultProps = {
|
2019-12-17 13:07:48 -05:00
|
|
|
snippetGid: 'gid://gitlab/PersonalSnippet/42',
|
2019-12-13 13:08:06 -05:00
|
|
|
};
|
|
|
|
|
2019-12-17 13:07:48 -05:00
|
|
|
function createComponent({ props = defaultProps, loading = false } = {}) {
|
2019-12-13 13:08:06 -05:00
|
|
|
const $apollo = {
|
|
|
|
queries: {
|
2019-12-17 13:07:48 -05:00
|
|
|
snippet: {
|
|
|
|
loading,
|
|
|
|
},
|
2019-12-13 13:08:06 -05:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
wrapper = shallowMount(SnippetApp, {
|
|
|
|
mocks: { $apollo },
|
|
|
|
propsData: {
|
|
|
|
...props,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2019-12-17 13:07:48 -05:00
|
|
|
it('renders loader while the query is in flight', () => {
|
|
|
|
createComponent({ loading: true });
|
|
|
|
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
2020-01-31 10:08:42 -05:00
|
|
|
it('renders all components after the query is finished', () => {
|
2019-12-13 13:08:06 -05:00
|
|
|
createComponent();
|
2019-12-17 13:07:48 -05:00
|
|
|
expect(wrapper.find(SnippetHeader).exists()).toBe(true);
|
2020-01-31 10:08:42 -05:00
|
|
|
expect(wrapper.find(SnippetTitle).exists()).toBe(true);
|
|
|
|
expect(wrapper.find(SnippetBlob).exists()).toBe(true);
|
2019-12-13 13:08:06 -05:00
|
|
|
});
|
|
|
|
});
|