I need to test with Frisby that at least on of 3 addresses has the data and is not null. Bellow is what is returned currently:
{ physicalAddress: null,
postalAddress:
{ addressNumber: 1234,
addressLine1: 'BlaBla 1',
addressLine2: 'BlaBla',
addressLine3: null,
addressLine4: null,
postalCode: '1234',
country: 'BlaBla',
},
emailAddress: null}
I want to write a test that passes if more than one of these address types returns with the correct data.
Something like this: (maybe there is something clever I could put in to replace the '^?^?^', if it was an array I Would have been able to use '?'.
.expectJSONTypes('^?^?^', {
addressNumber: Number,
addressLine1: String,
addressLine2: String,
postalCode: String,
country: String
})
This could be easier having a better structured response in which all addresses arrives in an array.
However, for the type of response you get, a solution is to use afterJSON() and jasmine-node matchers as follows:
.afterJSON(function(obj){
expect(obj.addr1 =! null || obj.addr2 =! null || obj.addr3 =! null).toBe(true);
})