summaryrefslogtreecommitdiff
path: root/spec/javascripts/blob
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2017-04-06 10:08:33 +0100
committerPhil Hughes <me@iamphill.com>2017-04-06 10:08:33 +0100
commit5e67b2fdb0d4d308b82a22290c1ac46d41d09469 (patch)
tree016a7dcef45b5c5b10c6707275ab51d4703d0fa1 /spec/javascripts/blob
parent49bdd8d63b577f079cdc47f7dd10ba83c677771a (diff)
downloadgitlab-ce-5e67b2fdb0d4d308b82a22290c1ac46d41d09469.tar.gz
Wait for the PDF to be loaded before doing anything
Closes #30531
Diffstat (limited to 'spec/javascripts/blob')
-rw-r--r--spec/javascripts/blob/pdf/index_spec.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/spec/javascripts/blob/pdf/index_spec.js b/spec/javascripts/blob/pdf/index_spec.js
index 19a4e55a9db..d3a4d04345b 100644
--- a/spec/javascripts/blob/pdf/index_spec.js
+++ b/spec/javascripts/blob/pdf/index_spec.js
@@ -3,6 +3,18 @@ import testPDF from './test.pdf';
describe('PDF renderer', () => {
let viewer;
+ let app;
+
+ const checkLoaded = (done) => {
+ if (app.loading) {
+ setTimeout(() => {
+ checkLoaded(done);
+ }, 100);
+ } else {
+ done();
+ }
+ };
+
preloadFixtures('static/pdf_viewer.html.raw');
beforeEach(() => {
@@ -21,11 +33,9 @@ describe('PDF renderer', () => {
describe('successful response', () => {
beforeEach((done) => {
- renderPDF();
+ app = renderPDF();
- setTimeout(() => {
- done();
- }, 500);
+ checkLoaded(done);
});
it('does not show loading icon', () => {
@@ -50,11 +60,9 @@ describe('PDF renderer', () => {
describe('error getting file', () => {
beforeEach((done) => {
viewer.dataset.endpoint = 'invalid/endpoint';
- renderPDF();
+ app = renderPDF();
- setTimeout(() => {
- done();
- }, 500);
+ checkLoaded(done);
});
it('does not show loading icon', () => {