UNPKG

@fye/xservices-client

Version:

FYE Micros Xservices Client

161 lines (144 loc) 5 kB
var expect = require('expect.js'); var CustomerService = require('../lib/customer'); var config = require('./service_config.json'); describe('CustomerService', function() { this.timeout(200000); var service = new CustomerService(config.service.opts, config.service.conns); describe('.searchCustomers', function() { var customers; var error; before(function(done) { service.searchCustomers({ serviceContext: config.context, name: 'nicholas penree' }, function(err, custs) { customers = custs; error = err; done(); }); }); it('should not return an error when passed context', function() { expect(error).to.be(null); }); it('should return a customers array', function() { expect(customers).to.be.an('array'); }); it('should return more than zero customers for "nicholas penree"', function() { expect(customers.length).to.be.above(0); }); it('should have the basic customer fields', function() { customers.forEach(function(customer) { expect(customer).to.have.keys([ 'address1', 'city', 'commercialCustomer', 'customerId', 'emailAddress', 'firstName', 'lastName', 'partyId', // 'phone', 'postal', 'state', 'active', 'cellPhoneContact', 'emailContact', 'faxContact', 'homePhoneContact', 'mailingList', 'privacyCard', 'workPhoneContact', 'birthday' ]); }); }); it('should properly convert data types', function() { customers.forEach(function(customer) { expect(customer.address1).to.be.a('string'); expect(customer.city).to.be.a('string'); expect(customer.commercialCustomer).to.be.a('boolean'); expect(customer.customerId).to.be.a('string'); expect(customer.emailAddress).to.be.a('string'); expect(customer.firstName).to.be.a('string'); expect(customer.lastName).to.be.a('string'); expect(customer.partyId).to.be.a('string'); // expect(customer.phone).to.be.a('string'); expect(customer.state).to.be.a('string'); expect(customer.active).to.be.a('boolean'); expect(customer.cellPhoneContact).to.be.a('boolean'); expect(customer.emailContact).to.be.a('boolean'); expect(customer.faxContact).to.be.a('boolean'); expect(customer.homePhoneContact).to.be.a('boolean'); expect(customer.mailingList).to.be.a('boolean'); expect(customer.privacyCard).to.be.a('boolean'); expect(customer.workPhoneContact).to.be.a('boolean'); expect(customer.birthday).to.be.a(Date); }); }); }); describe('.getCustomerByParty', function() { var customer; var error; before(function(done) { service.getCustomerByParty({ serviceContext: config.context, partyId: '4300100171' }, function(err, cust) { customer = cust; error = err; done(); }); }); it('should not return an error when passed context', function() { expect(error).to.be(null); }); it('should return a customer object', function() { expect(customer).to.be.an('object'); }); it('should have the basic customer fields', function() { expect(customer).to.have.keys([ 'address1', 'city', 'commercialCustomer', 'customerId', 'emailAddress', 'firstName', 'lastName', 'partyId', 'phone', 'postal', 'state', 'active', 'cellPhoneContact', 'emailContact', 'faxContact', 'homePhoneContact', 'mailingList', 'privacyCard', 'workPhoneContact', 'birthday' ]); }); it('should properly convert data types', function() { expect(customer.address1).to.be.a('string'); expect(customer.city).to.be.a('string'); expect(customer.commercialCustomer).to.be.a('boolean'); expect(customer.customerId).to.be.a('string'); expect(customer.emailAddress).to.be.a('string'); expect(customer.firstName).to.be.a('string'); expect(customer.lastName).to.be.a('string'); expect(customer.partyId).to.be.a('string'); expect(customer.phone).to.be.a('string'); expect(customer.state).to.be.a('string'); expect(customer.active).to.be.a('boolean'); expect(customer.cellPhoneContact).to.be.a('boolean'); expect(customer.emailContact).to.be.a('boolean'); expect(customer.faxContact).to.be.a('boolean'); expect(customer.homePhoneContact).to.be.a('boolean'); expect(customer.mailingList).to.be.a('boolean'); expect(customer.privacyCard).to.be.a('boolean'); expect(customer.workPhoneContact).to.be.a('boolean'); expect(customer.birthday).to.be.a(Date); }); }); });