Skip to content

Commit

Permalink
Brings coverage back up to 100 percent
Browse files Browse the repository at this point in the history
  • Loading branch information
coconutcraig committed Nov 18, 2018
1 parent 0943939 commit ae0a226
Showing 1 changed file with 88 additions and 83 deletions.
171 changes: 88 additions & 83 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,93 +108,98 @@ it('can book an appointment with all available parameters', async () => {
const start = '2018-01-01 12:00:00';
const attendee = new Attendee;
const answer = new Answer;

await resource
.at(1)
.for([2, 3])
.by(4)
.starting(start)
.with(
attendee
.named('Jane', 'Doe')
.reachable({
cell_phone: '5555555555',
email: '[email protected]',
phone: '5555555555',
work_phone: '5555555555',
})
.located({
address: '123 Fake St',
city: 'Fake City',
country: 'FC',
postcode: 'X0X 0X0',
region: 'FR',
timezone: 'UTC',
})
.messagable()
.provided('notes')
.speaks('es')
.answers(answer.for(1).is('this answer'))
)
.notify(Notifications.ALL)
.book();

expect(mockAxios.post).toHaveBeenCalledTimes(1);
expect(mockAxios.post).toBeCalledWith('appointments', {
data: {
attributes: {
location_id: 1,
service_id: [2, 3],
staff_id: 4,
start,
},
relationships: {
attendees: {
data: [
{
attributes: {
address: '123 Fake St',
cell_phone: '5555555555',
city: 'Fake City',
country: 'FC',
email: '[email protected]',
first_name: 'Jane',
lang: 'es',
last_name: 'Doe',
phone: '5555555555',
prov_state: 'FR',
receive_sms: true,
timezone: 'UTC',
work_phone: '5555555555',
zip_postal: 'X0X 0X0',
},
relationships: {
answers: {
data: [
{
attributes: {
question_id: 1,
value: 'this answer',
},
type: 'answers',
}
]
}
const notifications = [
Notifications.CLIENT,
Notifications.USER,
Notifications.ALL,
];

notifications.forEach(async (notification: object) => {
await resource
.at(1)
.for([2, 3])
.by(4)
.starting(start)
.with(
attendee
.named('Jane', 'Doe')
.reachable({
cell_phone: '5555555555',
email: '[email protected]',
phone: '5555555555',
work_phone: '5555555555',
})
.located({
address: '123 Fake St',
city: 'Fake City',
country: 'FC',
postcode: 'X0X 0X0',
region: 'FR',
timezone: 'UTC',
})
.messagable()
.provided('notes')
.speaks('es')
.answers(answer.for(1).is('this answer'))
)
.notify(notification)
.book();

expect(mockAxios.post).toBeCalledWith('appointments', {
data: {
attributes: {
location_id: 1,
service_id: [2, 3],
staff_id: 4,
start,
},
relationships: {
attendees: {
data: [
{
attributes: {
address: '123 Fake St',
cell_phone: '5555555555',
city: 'Fake City',
country: 'FC',
email: '[email protected]',
first_name: 'Jane',
lang: 'es',
last_name: 'Doe',
phone: '5555555555',
prov_state: 'FR',
receive_sms: true,
timezone: 'UTC',
work_phone: '5555555555',
zip_postal: 'X0X 0X0',
},
relationships: {
answers: {
data: [
{
attributes: {
question_id: 1,
value: 'this answer',
},
type: 'answers',
}
]
}
},
type: 'attendees'
},
type: 'attendees'
},
],
],
},
},
type: 'appointments',
},
type: 'appointments',
},
meta: {
notify: {
client: true,
user: true,
meta: {
notify: notification,
},
},
})
});

expect(mockAxios.post).toHaveBeenCalledTimes(3);
});
});

it('can retrieve matching appointments using a given set of matchers', async () => {
Expand Down

0 comments on commit ae0a226

Please sign in to comment.