Skip to content

Commit

Permalink
feat(MembershipsAdapter): add methods addRoomMember and removeRoomMember
Browse files Browse the repository at this point in the history
  • Loading branch information
thescripted authored and lalli-flores committed Mar 31, 2022
1 parent 1ef1ef0 commit fc35016
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/MembershipsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,32 @@ export default class MembershipsAdapter extends WebexAdapter {
new Error('getMembersFromDestination(destinationID, destinationType) must be defined in MembershipsAdapter'),
);
}

/**
* Returns an observable that emits the membership with a member added to the room.
*
* @param {string} personID ID of the person to add to a room
* @param {string} roomID ID of the room to add the person into
* @returns {external:Observable.<Membership>} Observable stream that emits the membership with the added member
* @memberof MembershipAdapter
*/
addRoomMember(personID, roomID) {
return throwError(
new Error('addRoomMember(personID, roomID) must be defined in MembershipsAdapter'),
);
}

/**
* Returns an observable that emits the membership with the member removed from the room.
*
* @param {string} personID ID of the person to remove from a room
* @param {string} roomID ID of the room the remove the person from
* @returns {external:Observable.<Membership>} Observable stream that emits the membership with the removed member
* @memberof MembershipAdapter
*/
removeRoomMember(personID, roomID) {
return throwError(
new Error('removeRoomMember(personID, roomID) must be defined in MembershipsAdapter'),
);
}
}
40 changes: 40 additions & 0 deletions src/MembershipsAdapter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,44 @@ describe('Memberships Adapter Interface', () => {
);
});
});

describe('addRoomMember()', () => {
test('returns an observable', () => {
const methodUnderTest = membershipsAdapter.addRoomMember();

expect(isObservable(methodUnderTest)).toBeTruthy();
});

test('errors because it needs to be defined', (done) => {
const message = 'addRoomMember(personID, roomID) must be defined in MembershipsAdapter';

membershipsAdapter.addRoomMember('personID', 'roomID').subscribe(
() => {},
(error) => {
expect(error.message).toBe(message);
done();
},
);
});
});

describe('removeRoomMember()', () => {
test('returns an observable', () => {
const methodUnderTest = membershipsAdapter.removeRoomMember();

expect(isObservable(methodUnderTest)).toBeTruthy();
});

test('errors because it needs to be defined', (done) => {
const message = 'removeRoomMember(personID, roomID) must be defined in MembershipsAdapter';

membershipsAdapter.removeRoomMember('personID', 'roomID').subscribe(
() => {},
(error) => {
expect(error.message).toBe(message);
done();
},
);
});
});
});

0 comments on commit fc35016

Please sign in to comment.