summaryrefslogtreecommitdiff
path: root/spec/frontend/blob/pdf
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 21:09:38 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-13 21:09:38 +0000
commit232e0a31f1e5d5b3a788dfc3dba8f8d41df36bf9 (patch)
treea2b11b9a805ef1165d8730934ba4a4f801f31870 /spec/frontend/blob/pdf
parent00fa950a34b1c94617110b150b8b2517d5241249 (diff)
downloadgitlab-ce-232e0a31f1e5d5b3a788dfc3dba8f8d41df36bf9.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob/pdf')
-rw-r--r--spec/frontend/blob/pdf/pdf_viewer_spec.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/frontend/blob/pdf/pdf_viewer_spec.js b/spec/frontend/blob/pdf/pdf_viewer_spec.js
new file mode 100644
index 00000000000..0eea3aea639
--- /dev/null
+++ b/spec/frontend/blob/pdf/pdf_viewer_spec.js
@@ -0,0 +1,67 @@
+import { shallowMount } from '@vue/test-utils';
+import { GlLoadingIcon } from '@gitlab/ui';
+
+import { FIXTURES_PATH } from 'spec/test_constants';
+import component from '~/blob/pdf/pdf_viewer.vue';
+import PdfLab from '~/pdf/index.vue';
+
+const testPDF = `${FIXTURES_PATH}/blob/pdf/test.pdf`;
+
+describe('PDF renderer', () => {
+ let wrapper;
+
+ const mountComponent = () => {
+ wrapper = shallowMount(component, {
+ propsData: {
+ pdf: testPDF,
+ },
+ });
+ };
+
+ const findLoading = () => wrapper.find(GlLoadingIcon);
+ const findPdfLab = () => wrapper.find(PdfLab);
+ const findLoadError = () => wrapper.find({ ref: 'loadError' });
+
+ beforeEach(() => {
+ mountComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ it('shows loading icon', () => {
+ expect(findLoading().exists()).toBe(true);
+ });
+
+ describe('successful response', () => {
+ beforeEach(() => {
+ findPdfLab().vm.$emit('pdflabload');
+ });
+
+ it('does not show loading icon', () => {
+ expect(findLoading().exists()).toBe(false);
+ });
+
+ it('renders the PDF', () => {
+ expect(findPdfLab().exists()).toBe(true);
+ });
+ });
+
+ describe('error getting file', () => {
+ beforeEach(() => {
+ findPdfLab().vm.$emit('pdflaberror', 'foo');
+ });
+
+ it('does not show loading icon', () => {
+ expect(findLoading().exists()).toBe(false);
+ });
+
+ it('shows error message', () => {
+ expect(findLoadError().text()).toBe(
+ 'An error occurred while loading the file. Please try again later.',
+ );
+ });
+ });
+});