Skip to content

Commit

Permalink
#12 delete all entries of a form
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Pollock committed Aug 22, 2018
1 parent 36aa4c8 commit 5b20a4e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
23 changes: 11 additions & 12 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions __tests__/EntriesClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,17 @@ describe( 'Entries client', () => {
},error => {});
expect(fetch.mock.calls).toHaveLength(1);
});

it( 'Deletes all entries of form', () => {
const r = {
message: 'All Entry Deleted'
};
fetch.mockResponseOnce(new Response(JSON.stringify(r)));
const client = new EntriesClient('https://hiroy.club/wp-json/cf-api/v1');
client.deleteEntries(formId).then( response => {
expect( response ).toEqual(r);
},error => {});
expect(fetch.mock.calls).toHaveLength(1);
});
});
});
10 changes: 10 additions & 0 deletions src/EntriesClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ export class EntriesClient extends WpClient {
return this.reqDelete(this.getEntryEndpoint( formId, entryId ) );
}

/**
* Delete all entries of a form
*
* @param {String} formId ID of form to get entries for.
* @return {Promise<any>}
*/
deleteEntries( formId: string ): Promise<any> {
return this.reqDelete(this.getEntriesEndpoint( formId ) );
}

/**
* Resent a single entry of a form
*
Expand Down

0 comments on commit 5b20a4e

Please sign in to comment.