Sunday, 12 March 2017

Multiple Chains With Using Chai Expect To Equal

I am trying to get rid of the var res if that is possible.

I was expecting to use

expect(booking.customers[0]).to.equal('CUST01').and.expect(booking.customers[0]).to.equal('CUST01') 

but that doesn't work.

Here is what works, but I'd like to condense where possible.

describe('#create', function() {

  it('should be able to create a booking with customer and provider', function(done) {
    var mock_customers = ['CUST01'];
    var mock_providers = ['PROV01'];

    bookings.create(mock_customers, mock_providers, function(err, booking) {
      var res = booking.customers[0] == 'CUST01' && booking.providers[0] == "PROV01";
      expect(res).to.equal(true); 
      done();
    });
  });

});

Thoughts?



via Jack Robson

No comments:

Post a Comment