diff --git a/test/mocks/fixtures/getGroupFromLicence.json b/test/mocks/fixtures/getGroupFromLicence.json index 454a05c..c510265 100644 --- a/test/mocks/fixtures/getGroupFromLicence.json +++ b/test/mocks/fixtures/getGroupFromLicence.json @@ -1,5 +1,6 @@ { "uuid": "8619e7a0-65b7-446b-9931-4197b3fe0cbf", + "name": "All users", "_rel": { "byTool": "KAT", "created": 1472335707780, diff --git a/test/mocks/fixtures/getGroupUsersByPage.json b/test/mocks/fixtures/getGroupUsersByPage.json new file mode 100644 index 0000000..205549d --- /dev/null +++ b/test/mocks/fixtures/getGroupUsersByPage.json @@ -0,0 +1,25 @@ +{ + "group": { + "_id": 1, + "labels": ["Group"], + "properties": { + "name": "All users", + "updated": 1500377383712, + "uuid": "8eb26ed7-68c8-44c6-b6ce-52d61500f301" + } + }, + "total": 1, + "items": [ + { + "uuid": "b2697f93-52d3-4d42-8409-bdf91b09e894", + "_rel": { + "byTool": "KAT", + "created": 1498743272070, + "count": 1, + "updated": 1498743272070, + "byUser": "c62c4485-7183-494c-a947-d754f5cd0a15" + } + } + ], + "count": 1 +} diff --git a/test/myFTClient.spec.js b/test/myFTClient.spec.js index a883571..421e769 100644 --- a/test/myFTClient.spec.js +++ b/test/myFTClient.spec.js @@ -356,6 +356,34 @@ describe('myFT Client proxy', () => { .catch(done); }); + it ('Should be able to update a group', done => { + const newGroupName = 'All users'; + if (mockAPI) { + nock(baseUrl) + .put(`/${myftConst.groupNodeName}/${uuids.validLicence}`) + .reply(200, () => ({})); + + nock(baseUrl) + .get(`/${myftConst.licenceNodeName}/${uuids.validLicence}/${myftConst.memberRelName}/${myftConst.groupNodeName}/${uuids.validLicence}`) + .reply(200, () => require('./mocks/fixtures/getGroupFromLicence')); + } + + myFT.updateGroup(uuids.validLicence, {"name": newGroupName}) + .then(resp => { + expect(resp).to.be.an('object'); + + return myFT.getGroupFromLicence(uuids.validLicence, uuids.validLicence); + }) + .then(resp => { + expectOwnProperties(resp, ['uuid', 'name', '_rel']); + expect(resp.uuid).to.equal(uuids.validLicence); + expect(resp.name).to.equal(newGroupName); + + done(); + }) + .catch(done); + }); + it ('Should be able to get a valid licence', done => { if (mockAPI) { nock(baseUrl) @@ -497,6 +525,30 @@ describe('myFT Client proxy', () => { .catch(done); }); + it ('Should get users registered to a group by pages', done => { + const page = 1; + const limit = 10; + if (mockAPI) { + nock(baseUrl) + .get(`/${myftConst.groupNodeName}/${uuids.validLicence}/${myftConst.memberRelName}/${myftConst.userNodeName}?page=${page}&limit=${limit}`) + .reply(200, () => require('./mocks/fixtures/getGroupUsersByPage')); + } + + myFT.getUsersForGroupByPage(uuids.validLicence, { page, limit }) + .then(usersResponse => { + expect(usersResponse).to.be.an('object'); + expectOwnProperties(usersResponse, ['group', 'total', 'items', 'count']); + + const items = usersResponse.items; + expect(items).to.be.an('array'); + expect(items.length).to.be.at.least(1); + expectOwnProperties(items, ['uuid']); + + done(); + }) + .catch(done); + }); + it ('Should get groups registered to a licence', done => { if (mockAPI) { nock(baseUrl)