-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MembershipsAdapter): add addRoomMember method
- Loading branch information
1 parent
5c390a6
commit 0cbc537
Showing
3 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,4 +151,55 @@ describe('Memberships SDK Adapter', () => { | |
}); | ||
}); | ||
}); | ||
|
||
describe('addRoomMember()', () => { | ||
let roomID; | ||
let personID; | ||
|
||
beforeEach(() => { | ||
roomID = 'roomID'; | ||
personID = 'personID'; | ||
}); | ||
afterEach(() => { | ||
roomID = null; | ||
personID = null; | ||
}); | ||
|
||
test('returns an observable', (done) => { | ||
expect(isObservable(membershipSDKAdapter.addRoomMember(personID, roomID))) | ||
.toBeTruthy(); | ||
done(); | ||
}); | ||
|
||
test('emits success when member is added to room', (done) => { | ||
membershipSDKAdapter.addRoomMember(personID, roomID).subscribe((membership) => { | ||
expect(membership).toEqual({ | ||
ID: 'id', | ||
roomID: 'roomID', | ||
personID: 'personID', | ||
personOrgID: 'organizationID', | ||
personEmail: '[email protected]', | ||
personDisplayName: 'Simon Damiano', | ||
isModerator: false, | ||
isMonitor: false, | ||
created: '', | ||
}); | ||
}); | ||
done(); | ||
}); | ||
|
||
test('emits error when sdk fails to add member to room', (done) => { | ||
const errorMsg = 'Error adding member to room'; | ||
|
||
mockSDK.memberships.create = jest.fn(() => Promise.reject(new Error(errorMsg))); | ||
|
||
membershipSDKAdapter.addRoomMember(personID, roomID).subscribe( | ||
() => {}, | ||
(error) => { | ||
expect(error.message).toBe(errorMsg); | ||
done(); | ||
}, | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters