-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from hellomuthu23/add-moderator-option
Allow members to be moderator
- Loading branch information
Showing
9 changed files
with
117 additions
and
7 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
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
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { isModerator } from './isModerator'; | ||
|
||
describe('isModerator', () => { | ||
it('should return true if the currentPlayerId matches the moderatorId', () => { | ||
const moderatorId = 'moderator123'; | ||
const currentPlayerId = 'moderator123'; | ||
const isAllowMembersToManageSession = false; | ||
|
||
const result = isModerator(moderatorId, currentPlayerId, isAllowMembersToManageSession); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false if the currentPlayerId does not match the moderatorId', () => { | ||
const moderatorId = 'moderator123'; | ||
const currentPlayerId = 'player456'; | ||
const isAllowMembersToManageSession = false; | ||
|
||
const result = isModerator(moderatorId, currentPlayerId, isAllowMembersToManageSession); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
|
||
it('should return false if isAllowMembersToManageSession is false', () => { | ||
const moderatorId = 'moderator123'; | ||
const currentPlayerId = 'player456'; | ||
const isAllowMembersToManageSession = false; | ||
|
||
const result = isModerator(moderatorId, currentPlayerId, isAllowMembersToManageSession); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
it('should return false if isAllowMembersToManageSession is undefined', () => { | ||
const moderatorId = 'moderator123'; | ||
const currentPlayerId = 'player456'; | ||
const isAllowMembersToManageSession = undefined; | ||
|
||
const result = isModerator(moderatorId, currentPlayerId, isAllowMembersToManageSession); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
it('should return true if isAllowMembersToManageSession is true', () => { | ||
const moderatorId = 'moderator123'; | ||
const currentPlayerId = 'moderator123'; | ||
const isAllowMembersToManageSession = true; | ||
|
||
const result = isModerator(moderatorId, currentPlayerId, isAllowMembersToManageSession); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
export const isModerator = (moderatorId: string, currentPlayerId: string | undefined) => { | ||
export const isModerator = ( | ||
moderatorId: string, | ||
currentPlayerId: string | undefined, | ||
isAllowMembersToManageSession: boolean | undefined, | ||
) => { | ||
if (isAllowMembersToManageSession) { | ||
return true; | ||
} | ||
return moderatorId === currentPlayerId; | ||
}; | ||
}; |