Skip to content

Commit

Permalink
Merge pull request #80 from philals/f-contactscheme
Browse files Browse the repository at this point in the history
F contactscheme
  • Loading branch information
jordanwalsh23 authored Aug 28, 2017
2 parents 728cf9f + 7341bb3 commit 5b28154
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 1 addition & 5 deletions lib/entities/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Entity = require('./entity')
* ACCOUNTING API SHARED SCHEMAS
*/

var AddressDetailsSchema = Entity.SchemaObject({
module.exports.AddressSchema = Entity.SchemaObject({
AddressLine1: { type: String, toObject: 'always' },
AddressLine2: { type: String, toObject: 'always' },
AddressLine3: { type: String, toObject: 'always' },
Expand All @@ -17,10 +17,6 @@ var AddressDetailsSchema = Entity.SchemaObject({
AddressType: { type: String, toObject: 'always' }
})

module.exports.AddressSchema = Entity.SchemaObject({
Address: { type: AddressDetailsSchema, toObject: 'always' }
});

module.exports.PhoneSchema = Entity.SchemaObject({
PhoneNumber: { type: String, toObject: 'always' },
PhoneAreaCode: { type: String, toObject: 'always' },
Expand Down
22 changes: 17 additions & 5 deletions test/core/contacts_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ describe('contacts', () => {
Name: `Johnnies Coffee ${Math.random()}`,
FirstName: 'John',
LastName: 'Smith',
Addresses: [{
AddressType: "POBOX",
AddressLine1: "P O Box 123",
City: "Wellington",
PostalCode: "6011",
AttentionTo: "Andrea"
}]
};

let contactIDsList = [];
Expand All @@ -34,6 +41,10 @@ describe('contacts', () => {
);
expect(response.entities[0].LastName).to.equal(sampleContact.LastName);

expect(response.entities[0].Addresses.filter((address) => {
return address.City == sampleContact.Addresses[0].City
}).length).to.equal(1);

sampleContact = response.entities[0];

done();
Expand Down Expand Up @@ -69,7 +80,7 @@ describe('contacts', () => {
expect(contact.ContactID).to.not.equal('');
expect(contact.ContactID).to.not.equal(undefined);

if(contactIDsList.length < 5) {
if (contactIDsList.length < 5) {
contactIDsList.push(contact.ContactID);
}
});
Expand Down Expand Up @@ -116,7 +127,7 @@ describe('contacts', () => {
done(wrapError(err));
});
});

it('get list of IDs', done => {
currentApp.core.contacts
.getContacts({
Expand All @@ -128,15 +139,15 @@ describe('contacts', () => {
contacts.forEach(contact => {
expect(contact.ContactID).to.be.oneOf(contactIDsList);
});

done();
})
.catch(err => {
console.error(util.inspect(err, null, null));
done(wrapError(err));
});
});

it('get - invalid modified date', done => {
currentApp.core.contacts
.getContacts({ modifiedAfter: 'cats' })
Expand All @@ -153,7 +164,7 @@ describe('contacts', () => {
it('create multiple contacts', done => {
const contacts = [];

for (let i = 0; i < 2; i += 1) {
for (let i = 0;i < 2;i += 1) {
contacts.push(
currentApp.core.contacts.newContact({
Name: `Johnnies Coffee ${Math.random()}`,
Expand Down Expand Up @@ -214,6 +225,7 @@ describe('contacts', () => {
})
.then(updatedContact => {
expect(updatedContact.entities[0].Name).to.equal(newName);
expect(updatedContact.entities[0].Addresses.filter((address) => {return address.City == "Melbourne"}).length).to.equal(1);
done();
})
.catch(err => {
Expand Down

0 comments on commit 5b28154

Please sign in to comment.