summaryrefslogtreecommitdiff
path: root/spec/frontend/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/snippets')
-rw-r--r--spec/frontend/snippets/components/app_spec.js6
-rw-r--r--spec/frontend/snippets/components/snippet_blob_view_spec.js54
2 files changed, 59 insertions, 1 deletions
diff --git a/spec/frontend/snippets/components/app_spec.js b/spec/frontend/snippets/components/app_spec.js
index 6576e5b075f..a683ed9aaba 100644
--- a/spec/frontend/snippets/components/app_spec.js
+++ b/spec/frontend/snippets/components/app_spec.js
@@ -1,5 +1,7 @@
import SnippetApp from '~/snippets/components/app.vue';
import SnippetHeader from '~/snippets/components/snippet_header.vue';
+import SnippetTitle from '~/snippets/components/snippet_title.vue';
+import SnippetBlob from '~/snippets/components/snippet_blob_view.vue';
import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
@@ -35,8 +37,10 @@ describe('Snippet view app', () => {
expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
});
- it('renders SnippetHeader component after the query is finished', () => {
+ it('renders all components after the query is finished', () => {
createComponent();
expect(wrapper.find(SnippetHeader).exists()).toBe(true);
+ expect(wrapper.find(SnippetTitle).exists()).toBe(true);
+ expect(wrapper.find(SnippetBlob).exists()).toBe(true);
});
});
diff --git a/spec/frontend/snippets/components/snippet_blob_view_spec.js b/spec/frontend/snippets/components/snippet_blob_view_spec.js
new file mode 100644
index 00000000000..8401c08b1da
--- /dev/null
+++ b/spec/frontend/snippets/components/snippet_blob_view_spec.js
@@ -0,0 +1,54 @@
+import { shallowMount } from '@vue/test-utils';
+import SnippetBlobView from '~/snippets/components/snippet_blob_view.vue';
+import BlobEmbeddable from '~/blob/components/blob_embeddable.vue';
+import {
+ SNIPPET_VISIBILITY_PRIVATE,
+ SNIPPET_VISIBILITY_INTERNAL,
+ SNIPPET_VISIBILITY_PUBLIC,
+} from '~/snippets/constants';
+
+describe('Blob Embeddable', () => {
+ let wrapper;
+ const snippet = {
+ id: 'gid://foo.bar/snippet',
+ webUrl: 'https://foo.bar',
+ visibilityLevel: SNIPPET_VISIBILITY_PUBLIC,
+ };
+
+ function createComponent(props = {}) {
+ wrapper = shallowMount(SnippetBlobView, {
+ propsData: {
+ snippet: {
+ ...snippet,
+ ...props,
+ },
+ },
+ });
+ }
+
+ afterEach(() => {
+ wrapper.destroy();
+ });
+
+ it('renders blob-embeddable component', () => {
+ createComponent();
+ expect(wrapper.find(BlobEmbeddable).exists()).toBe(true);
+ });
+
+ it('does not render blob-embeddable for internal snippet', () => {
+ createComponent({
+ visibilityLevel: SNIPPET_VISIBILITY_INTERNAL,
+ });
+ expect(wrapper.find(BlobEmbeddable).exists()).toBe(false);
+
+ createComponent({
+ visibilityLevel: SNIPPET_VISIBILITY_PRIVATE,
+ });
+ expect(wrapper.find(BlobEmbeddable).exists()).toBe(false);
+
+ createComponent({
+ visibilityLevel: 'foo',
+ });
+ expect(wrapper.find(BlobEmbeddable).exists()).toBe(false);
+ });
+});