How to use the api/utils/jasmineHelpers.catchErrors function in api

To help you get started, we’ve selected a few api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huridocs / uwazi / nightmare / paths / uploads.spec.js View on Github external
.waitForCardToBeCreated(expectedTitle)
        .wait(() => {
          console.log(1);
          return true;
        })
        .waitForCardStatus(selectors.uploadsView.firstDocument, 'Conversion failed')
        .wait(() => {
          console.log(2);
          return true;
        })
        .getResultsAsJson()
        .then((results) => {
          expect(results[0].title).toBe(expectedTitle);
          done();
        })
        .catch(catchErrors(done));
      });
    });
github huridocs / uwazi / app / api / users / specs / routes.spec.js View on Github external
it('should call users update with the body', (done) => {
        spyOn(users, 'resetPassword').and.returnValue(Promise.resolve());
        const req = { body: 'changes' };
        routes.post('/api/resetpassword', req)
        .then(() => {
          expect(users.resetPassword).toHaveBeenCalledWith('changes');
          done();
        })
        .catch(catchErrors(done));
      });
    });
github huridocs / uwazi / app / api / templates / specs / templates.spec.js View on Github external
it('should return number of templates using a thesauri', done => {
      templates
        .countByThesauri('thesauri1')
        .then(result => {
          expect(result).toBe(3);
          done();
        })
        .catch(catchErrors(done));
    });
github huridocs / uwazi / app / api / relationtypes / specs / relationtypes.spec.js View on Github external
it('should create a new one and return it', (done) => {
        relationtypes.save({ name: 'Indiferent', properties: [] })
        .then((result) => {
          expect(result.name).toBe('Indiferent');
          done();
        })
        .catch(catchErrors(done));
      });
github huridocs / uwazi / app / api / relationtypes / specs / relationtypes.spec.js View on Github external
it('should return an error', (done) => {
        const relationtype = { name: 'Against', properties: [] };
        return relationtypes.save(relationtype)
        .then(catchErrors(done))
        .catch((error) => {
          expect(error).toBe('duplicated_entry');
          done();
        });
      });
    });
github huridocs / uwazi / nightmare / paths / filters.spec.js View on Github external
it('should create a group called Test Group', (done) => {
      nightmare
      .clearInput(selectors.settingsView.newFilterGroupForm)
      .write(selectors.settingsView.newFilterGroupForm, 'Test Group')
      .waitToClick(selectors.settingsView.filtrableTypesSaveButton)
      .wait('.alert.alert-success')
      .isVisible('.alert.alert-success')
      .then((result) => {
        expect(result).toBe(true);
        done();
      })
      .catch(catchErrors(done));
    });
github huridocs / uwazi / nightmare / paths / graphs.spec.js View on Github external
it('should insert Pie chart graph in page', (done) => {
      nightmare
      .evaluate(() => document.querySelector('div.panel-body.page-viewer.document-viewer > div > div.tab-content.tab-content-visible > textarea').value = '')
      .write(localSelectors.pageContentsInput, '</p><Dataset />')
      .write(localSelectors.pageContentsInput, graphs.pieChart)
      .waitToClick(localSelectors.savePageButton)
      .wait('div.panel-body.page-viewer.document-viewer > div.alert.alert-info:first-of-type')
      .getInnerText('div.panel-body.page-viewer.document-viewer > div.alert.alert-info:first-of-type')
      .then((text) => {
        expect(text).toContain('/page');
        expect(text).toContain('(view page)');
      })
      .then(() => { done(); })
      .catch(catchErrors(done));
    });
github huridocs / uwazi / app / api / migrations / migrations / 4-pdf_thumbnails / specs / 4-pdf_thumbnails.spec.js View on Github external
beforeEach((done) => {
    spyOn(process.stdout, 'write');
    spyOn(errorLog, 'error');
    paths.uploadDocumentsPath = __dirname;
    testingDB.clearAllAndLoad(fixtures).then(done).catch(catchErrors(done));
  });
github huridocs / uwazi / app / api / migrations / migrations / 14-relationships-to-objects / specs / 14-relationships-to-objects.spec.js View on Github external
beforeEach((done) => {
    spyOn(process.stdout, 'write');
    testingDB.clearAllAndLoad(fixtures).then(done).catch(catchErrors(done));
  });
github huridocs / uwazi / nightmare / paths / templates.spec.js View on Github external
nightmare
      .waitToClick(editPropertySelector(textPropertyIndex))
      .waitToClick(hideLabelSelector(textPropertyIndex))
      .waitToClick(usedAsFilterSelector(textPropertyIndex))
      .waitToClick(editPropertySelector(relationshipPropertyIndex))
      .select(localSelectors.relationShipSelect, '5aae90e0bfbf88e5ae28b18c')
      .waitToClick(localSelectors.saveTemplate)
      .waitToClick('.alert.alert-success')
      .waitToClick(localSelectors.backbutton)
      .getInnerText(localSelectors.template)
      .then((text) => {
        expect(text).toContain('Testing Document Type');
      })
      .then(() => { done(); })
      .catch(catchErrors(done));
    });