Skip to content

Commit

Permalink
Fix avatar upload (#247)
Browse files Browse the repository at this point in the history
* Fix core.avatar.upload method and test

* 4.9.0-6-g572c794
  • Loading branch information
llunaCreixent authored Oct 27, 2023
1 parent 34fcaa9 commit 96e1e3d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@circles/core",
"version": "4.9.0",
"version": "4.9.0-6-g572c794",
"description": "Common methods to interact with the Circles ecosystem",
"main": "lib/index.js",
"contributors": [
Expand Down
13 changes: 2 additions & 11 deletions src/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,13 @@ export default function createAvatarModule(web3, utils) {
* @namespace core.avatar.upload
*
* @param {Object} account - web3 account instance
* @param {Object} userOptions - options
* @param {object} userOptions.data - avatar image file
* @param {Object} data - avatar image file
*
* @return {object} - Returns url, file name and file type of the uploaded image
*/
upload: (account, userOptions) => {
upload: (account, data) => {
checkAccount(web3, account);

const options = checkOptions(userOptions, {
data: {
type: 'object',
},
});

const { data } = options;

return utils.requestAPI({
path: ['uploads', 'avatar'],
method: 'POST',
Expand Down
2 changes: 1 addition & 1 deletion test/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Avatar - upload and delete', () => {
it('should return a success response', async () => {
const data = {};
mockApiAvatarUpload(data);
const result = await core.avatar.upload(account, { data });
const result = await core.avatar.upload(account, data);
expect(result.data.url).toEqual(expect.stringContaining('https://'));

mockApiAvatarDelete(result.data.url);
Expand Down

0 comments on commit 96e1e3d

Please sign in to comment.