How to use the api/utils/testing_db.clearAllAndLoad 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 / app / api / csv / specs / csvLoader.spec.js View on Github external
it('should stop processing on the first error', async () => {
      const testingLoader = new CSVLoader();

      await db.clearAllAndLoad(fixtures);
      spyOn(entities, 'save').and.callFake(entity => Promise.reject(new Error(`error-${entity.title}`)));

      try {
        await testingLoader.load(csvFile, template1Id);
        fail('should fail');
      } catch (e) {
        expect(e).toEqual(new Error('error-title1'));
      }
    });
    it('should throw the error that occurred even if it was not the first row', async () => {
github huridocs / uwazi / app / api / search / specs / index.spec.js View on Github external
beforeAll((done) => {
    db.clearAllAndLoad({}).then(done);
  });
github huridocs / uwazi / app / api / relationships / specs / routes.spec.js View on Github external
beforeEach((done) => {
    routes = instrumentRoutes(relationshipsRroutes);
    spyOn(relationships, 'save').and.returnValue(Promise.resolve());
    spyOn(relationships, 'delete').and.returnValue(Promise.resolve());
    db.clearAllAndLoad({}).then(done);
  });
github huridocs / uwazi / app / api / migrations / migrations / 2-sanitize_empty_geolocations / specs / 2-sanitize_empty_geolocations.spec.js View on Github external
beforeEach((done) => {
    spyOn(process.stdout, 'write');
    testingDB.clearAllAndLoad(fixtures).then(done).catch(catchErrors(done));
  });
github huridocs / uwazi / app / api / topicclassification / specs / common.spec.ts View on Github external
beforeEach(async () => {
    await db.clearAllAndLoad(fixtures);
  });
github huridocs / uwazi / app / api / templates / specs / templates.spec.js View on Github external
beforeEach(done => {
    spyOn(translations, 'addContext').and.returnValue(Promise.resolve());
    db.clearAllAndLoad(fixtures)
      .then(done)
      .catch(catchErrors(done));
  });
github huridocs / uwazi / app / api / documents / specs / documents.spec.js View on Github external
beforeEach((done) => {
    spyOn(relationships, 'saveEntityBasedReferences').and.returnValue(Promise.resolve());
    spyOn(search, 'delete').and.returnValue(Promise.resolve());
    spyOn(search, 'bulkIndex').and.returnValue(Promise.resolve());
    mockID();
    db.clearAllAndLoad(fixtures).then(done).catch(catchErrors(done));
  });
github huridocs / uwazi / app / api / odm / specs / model.spec.ts View on Github external
beforeEach(async () => {
    await testingDB.clearAllAndLoad({});
  });
github huridocs / uwazi / app / api / migrations / migrations / 5-geolocation_fields / specs / 5-geolocation_fields.spec.js View on Github external
beforeEach((done) => {
    spyOn(process.stdout, 'write');
    testingDB.clearAllAndLoad(fixtures).then(done).catch(catchErrors(done));
  });
github huridocs / uwazi / app / api / odm / specs / model.spec.js View on Github external
beforeEach(async () => {
    await testingDB.clearAllAndLoad({});
  });