-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Support reactions in the SuperGroupChannel (#1029)
### ChangeLog & Feature * Support reaction feature in the SuperGroupChannel ### Internal change * modify the `getIsReactionEnabled`
- Loading branch information
Showing
12 changed files
with
139 additions
and
155 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
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 |
---|---|---|
@@ -1,124 +1,90 @@ | ||
import { getIsReactionEnabled } from '../getIsReactionEnabled'; | ||
import type { GroupChannel } from '@sendbird/chat/groupChannel'; | ||
|
||
describe('Global-utils/getIsReactionEnabled', () => { | ||
it('should enable as a default', () => { | ||
expect(getIsReactionEnabled({})).toBeTrue(); | ||
import type { SendBirdStateConfig } from '../../lib/types'; | ||
import { getIsReactionEnabled } from '../getIsReactionEnabled'; | ||
|
||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
})).toBeTrue(); | ||
expect(getIsReactionEnabled({ | ||
moduleLevel: true, | ||
})).toBeTrue(); | ||
const normalGroupChannel = (props?) => ({ | ||
isBroadcast: false, | ||
isEphemeral: false, | ||
isSuper: false, | ||
...props, | ||
} as GroupChannel); | ||
const normalConfigs = (props?, groupChannelProps?) => ({ | ||
groupChannel: { | ||
enableReactions: true, | ||
enableReactionsSupergroup: false, | ||
...groupChannelProps, | ||
}, | ||
...props, | ||
} as SendBirdStateConfig); | ||
|
||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
moduleLevel: true, | ||
})).toBeTrue(); | ||
describe('Global-utils/getIsReactionEnabled', () => { | ||
it('should prioritize the moduleLevel than global config', () => { | ||
const moduleLevel = true; | ||
expect(getIsReactionEnabled({ | ||
channel: normalGroupChannel(), | ||
config: normalConfigs(), | ||
moduleLevel, | ||
})).toBe(moduleLevel); | ||
const moduleLevel2 = false; | ||
expect(getIsReactionEnabled({ | ||
channel: normalGroupChannel(), | ||
config: normalConfigs(), | ||
moduleLevel: moduleLevel2, | ||
})).toBe(moduleLevel2); | ||
}); | ||
|
||
it('should disable if set values are false', () => { | ||
expect(getIsReactionEnabled({ | ||
globalLevel: false, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
moduleLevel: false, | ||
})).toBeFalse(); | ||
|
||
it('should prioritize the isSuper than moduleLevel', () => { | ||
const isSuper = true; | ||
expect(getIsReactionEnabled({ | ||
globalLevel: false, | ||
moduleLevel: false, | ||
})).toBeFalse(); | ||
}); | ||
|
||
it('should have higher priority to the moduleLevel than globalLevel', () => { | ||
channel: normalGroupChannel({ isSuper }), | ||
config: normalConfigs(), | ||
moduleLevel: true, | ||
})).toBe(false); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
channel: normalGroupChannel({ isSuper }), | ||
config: normalConfigs(), | ||
moduleLevel: false, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: false, | ||
moduleLevel: true, | ||
})).toBeTrue(); | ||
})).toBe(false); | ||
}); | ||
|
||
it('should disable in the special type channels', () => { | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
isBroadcast: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
isBroadcast: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
|
||
expect(getIsReactionEnabled({ | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
moduleLevel: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
|
||
it('should prioritize moduleLevel than enableReactionsSupergroup', () => { | ||
const isSuper = true; | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
channel: normalGroupChannel({ isSuper }), | ||
config: normalConfigs({}, { enableReactionsSupergroup: true }), | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
})).toBeFalse(); | ||
})).toBe(true); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
moduleLevel: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
channel: normalGroupChannel({ isSuper }), | ||
config: normalConfigs({}, { enableReactionsSupergroup: true }), | ||
moduleLevel: false, | ||
})).toBe(false); | ||
}); | ||
|
||
it('should disable if only one special channel type is true', () => { | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
moduleLevel: true, | ||
isBroadcast: false, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
it('should be false when it is broadcast or ephemeral channel', () => { | ||
const isBroadcast = true; | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
channel: normalGroupChannel({ isBroadcast }), | ||
config: normalConfigs(), | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
isSuper: false, | ||
})).toBeFalse(); | ||
})).toBe(false); | ||
expect(getIsReactionEnabled({ | ||
globalLevel: true, | ||
isBroadcast: false, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
channel: normalGroupChannel({ isBroadcast }), | ||
config: normalConfigs(), | ||
moduleLevel: false, | ||
})).toBe(false); | ||
|
||
const isEphemeral = true; | ||
expect(getIsReactionEnabled({ | ||
channel: normalGroupChannel({ isEphemeral }), | ||
config: normalConfigs(), | ||
moduleLevel: true, | ||
isBroadcast: true, | ||
isSuper: false, | ||
})).toBeFalse(); | ||
})).toBe(false); | ||
expect(getIsReactionEnabled({ | ||
isBroadcast: false, | ||
isSuper: true, | ||
})).toBeFalse(); | ||
expect(getIsReactionEnabled({ | ||
isBroadcast: true, | ||
isSuper: false, | ||
})).toBeFalse(); | ||
channel: normalGroupChannel({ isEphemeral }), | ||
config: normalConfigs(), | ||
moduleLevel: false, | ||
})).toBe(false); | ||
}); | ||
}); |
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
Oops, something went wrong.