Skip to content

Commit

Permalink
Merge branch '7-data.updateTag-Request' into 'dev'
Browse files Browse the repository at this point in the history
Resolve "Add data.updateTag request"

Closes #7

See merge request manuscript/surix/app-service!14
  • Loading branch information
Lydia Nishimwe committed Nov 1, 2018
2 parents fe7247a + 73e8d0c commit f8b4624
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const requests = Surix.requests;
- `addTagsToEntity`: Add tags to an existing entity.
- `removeTagsFromEntity`: Removes tags from an entity.
- `getTags`: Gets all the entity tags in the project.
- `updateTag`: Updates the specified tag in an entity. <!--readme added-->
- `project`: Fetches the current Surix project.
- `getAppData`: Fetches app data stored by the app in the current project
- `updateAppData`: Updates/adds app data to the current project
Expand Down Expand Up @@ -168,6 +169,22 @@ service.request(requests.data.removeTagsFromEntity, args).then((updatedEntity) =

**Note**: Tags that are not in the entity will be ignored.

### Updating a tag in an entity
```javascript
const args = {
tags: 'people',
update: {
name: 'persons'
}
};

surix.request(requests.data.updateTag, args).then(updatedTag => {
//Tag updated successfully
}).catch(error) => {
//Error
});
```

### Get all tags in the project
```javascript
service.request(requests.data.getTags).then((tags) => {
Expand Down
1 change: 1 addition & 0 deletions build/dist/src/requests.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export declare const requests: {
addTagsToEntity: string;
removeTagsFromEntity: string;
getTags: string;
updateTag: string,
getAppData: string;
updateAppData: string;
};
Expand Down
1 change: 1 addition & 0 deletions dist/client-service.js

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

1 change: 1 addition & 0 deletions src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const requests = {
addTagsToEntity: 'data.addTagsToEntity',
removeTagsFromEntity: 'data.removeTagsFromEntity',
getTags: 'data.getTags',
updateTag: 'data.updateTag',
getAppData: 'data.getAppData',
updateAppData: 'data.updateAppData'
},
Expand Down
17 changes: 17 additions & 0 deletions tests/service.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Service, requests } from '..';
import { request } from 'http';

jest.spyOn(global.window.parent , 'postMessage');

Expand Down Expand Up @@ -66,5 +67,21 @@ describe('Requests', async () => {

expect(window.parent.postMessage).toHaveBeenCalled();
});
test('Update Tag', async() => {
const args = {
tag: 'current tag name',
upadate: {
name: 'new tag name'
}
};
surix.request(requests.data.updateTag, args).then(updatedTag => {
//Tag updated successfully
}).catch((error) => {
//Error
});

expect(window.parent.postMessage).toHaveBeenCalled();
});

});
});

0 comments on commit f8b4624

Please sign in to comment.