Skip to content

Commit

Permalink
Fixes incorrect usage of delete axios request body data
Browse files Browse the repository at this point in the history
  • Loading branch information
craigpaul committed Nov 14, 2019
1 parent 3f845ad commit 695bf35
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
60 changes: 31 additions & 29 deletions src/resources/appointment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ it('can cancel the given appointment for the given attendee', async () => {
await resource.cancel(1, 2);

expect(mockAxios.delete).toHaveBeenCalledTimes(1);
expect(mockAxios.delete).toHaveBeenCalledWith('appointments/1/2', {});
expect(mockAxios.delete).toHaveBeenCalledWith('appointments/1/2', { data: {} });
});

it('can cancel the given appointment for the given attendee while provided responses', async () => {
Expand All @@ -317,37 +317,39 @@ it('can cancel the given appointment for the given attendee while provided respo

expect(mockAxios.delete).toHaveBeenCalledWith('appointments/1/2', {
data: {
relationships: {
attendees: {
data: [
{
id: 2,
relationships: {
responses: {
data: [
{
attributes: {
form_question_id: 1,
value: 'the response',
data: {
relationships: {
attendees: {
data: [
{
id: 2,
relationships: {
responses: {
data: [
{
attributes: {
form_question_id: 1,
value: 'the response',
},
type: 'responses',
},
type: 'responses',
},
{
attributes: {
form_option_id: 1,
form_question_id: 2,
{
attributes: {
form_option_id: 1,
form_question_id: 2,
},
type: 'responses',
},
type: 'responses',
},
]
}
},
type: 'attendees',
}
]
}
]
}
},
type: 'attendees',
}
]
}
},
type: 'appointments',
},
type: 'appointments',
},
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/resources/appointment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default class Appointment extends Conditional implements AppointmentResou
}

public async cancel(appointment: number, attendee: number): Promise<any> {
return await this.client.delete(`appointments/${appointment}/${attendee}`, this.params());
return await this.client.delete(`appointments/${appointment}/${attendee}`, { data: this.params() });
}

public content(content: string): this {
Expand Down

0 comments on commit 695bf35

Please sign in to comment.