How to use the @lykmapipo/mongoose-test-helpers.expect function in @lykmapipo/mongoose-test-helpers

To help you get started, we’ve selected a few @lykmapipo/mongoose-test-helpers 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 lykmapipo / mongoose-gridfs / test / model.spec.js View on Github external
it('should create gridfs model with plugins', () => {
    const Image = createModel({ modelName: 'Image' }, (schema) => {
      schema.statics.stats = (optns, done) => done(null, optns);
    });

    expect(Image).to.exist;
    expect(Image.schema).to.exist;
    expect(Image.modelName).to.be.equal('Image');
    expect(Image.collection.name).to.be.equal('images.files');
    expect(Image.stats).to.exist.and.be.a('function');
  });
github lykmapipo / mongoose-rest-actions / test / unit / index.spec.js View on Github external
it('should be able to hide default properties', () => {
    let user = User.fake();
    user = user.toObject();

    expect(user).to.exist;
    expect(user.name).to.exist;
    expect(user.password).to.not.exist;
  });
github lykmapipo / mongoose-rest-actions / test / integration / patch.spec.js View on Github external
Guardian.patch(updates, (error, updated) => {
      expect(error).to.not.exist;
      expect(updated).to.exist;
      expect(updated._id).to.exist.and.be.eql(father._id);
      expect(updated.createdAt).to.exist.and.be.eql(father.createdAt);
      expect(updated.updatedAt).to.exist.and.be.above(father.updatedAt);
      expect(updated.name).to.be.eql(updates.name);
      done(error, updated);
    });
  });
github lykmapipo / mongoose-rest-actions / test / unit / get.spec.js View on Github external
User.getById(options, (error, found) => {
      Mock.verify();
      Mock.restore();

      expect(findById).to.have.been.calledOnce;
      expect(findById).to.have.been.calledWith(user._id);
      expect(where).to.have.been.calledOnce;
      expect(where).to.have.been.calledWith(options.filter);
      expect(exec).to.have.been.calledOnce;
      expect(beforeGetById).to.have.been.calledOnce;
      expect(afterGetById).to.have.been.calledOnce;

      done(error, found);
    });
  });
github lykmapipo / mongoose-rest-actions / test / integration / put.spec.js View on Github external
Child.put(child._id, updates, (error, updated) => {
      expect(error).to.not.exist;
      expect(updated).to.exist;
      expect(updated._id).to.exist.and.be.eql(child._id);
      expect(updated.createdAt).to.exist.and.be.eql(child.createdAt);
      expect(updated.updatedAt).to.exist.and.be.above(child.updatedAt);
      expect(updated.name).to.be.eql(updates.name);
      expect(updated.father).to.exist;
      done(error, updated);
    });
  });
github lykmapipo / mongoose-rest-actions / test / integration / get.spec.js View on Github external
Child.fresh(options, (error, results) => {
      expect(error).to.not.exist;
      expect(results).to.exist;
      expect(results.data).to.exist;
      expect(results.data).to.have.length(0);
      expect(results.total).to.exist;
      expect(results.total).to.be.equal(0);
      expect(results.limit).to.exist;
      expect(results.limit).to.be.equal(10);
      expect(results.skip).to.exist;
      expect(results.skip).to.be.equal(0);
      expect(results.page).to.exist;
      expect(results.page).to.be.equal(1);
      expect(results.pages).to.exist;
      expect(results.pages).to.be.equal(0);
      expect(results.lastModified).to.exist;
      expect(results.hasMore).to.exist;
      expect(results.lastModified).to.be.eql(lastModified);
      done(error, results);
    });
  });
github lykmapipo / mongoose-rest-actions / test / integration / getById.spec.js View on Github external
Guardian.getById(guardian._id, error => {
        expect(error).to.exist;
        expect(error.name).to.be.equal('DocumentNotFoundError');
        expect(error.status).to.exist.and.be.equal(400);
        done();
      });
    });
github lykmapipo / mongoose-gridfs / test / model.spec.js View on Github external
Archive.patch(archive._id, updates, (error, updated) => {
        expect(error).to.not.exist;
        expect(updated).to.exist;
        expect(updated._id).to.exist;
        expect(updated.filename).to.exist;
        expect(updated.contentType).to.exist;
        expect(updated.length).to.exist;
        expect(updated.chunkSize).to.exist;
        expect(updated.uploadDate).to.exist;
        expect(updated.md5).to.exist;
        expect(updated.aliases).to.exist.and.be.eql(updates.aliases);
        done(error, updated);
      });
    });
github lykmapipo / mongoose-rest-actions / test / integration / get.spec.js View on Github external
Child.get(options, (error, results) => {
      expect(error).to.not.exist;
      expect(results).to.exist;
      expect(results.data).to.exist;
      expect(results.data).to.have.length.at.least(1);
      expect(results.total).to.exist;
      expect(results.total).to.be.at.least(1);
      expect(results.limit).to.exist;
      expect(results.limit).to.be.equal(10);
      expect(results.skip).to.exist;
      expect(results.skip).to.be.equal(0);
      expect(results.page).to.exist;
      expect(results.page).to.be.equal(1);
      expect(results.pages).to.exist;
      expect(results.pages).to.be.equal(1);
      expect(results.lastModified).to.exist;
      expect(results.hasMore).to.exist;
      expect(_.maxBy(results.data, 'updatedAt').updatedAt)
github lykmapipo / mongoose-gridfs / test / model.spec.js View on Github external
Photo.write(options, readableStream, (error, created) => {
        expect(error).to.not.exist;
        expect(created).to.exist;
        expect(created._id).to.exist;
        expect(created.filename).to.exist;
        expect(created.contentType).to.exist;
        expect(created.length).to.exist;
        expect(created.chunkSize).to.exist;
        expect(created.uploadDate).to.exist;
        expect(created.md5).to.exist;
        done(error, created);
      });
    });