refactor(formatters): Add support for object and name param in formatEmoji() (#10076)

* feat: add support for name param and object in `formatEmoji()`

* Update formatters.ts

* refactor: swap priority

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
codershiba
2024-01-13 16:32:41 +05:30
committed by GitHub
parent 136c66c213
commit 7b8e0debeb
3 changed files with 104 additions and 6 deletions

View File

@@ -176,6 +176,40 @@ describe('Message formatters', () => {
test('GIVEN animated emojiId THEN returns "<a:_:${emojiId}>"', () => {
expect<`<a:_:827220205352255549>`>(formatEmoji('827220205352255549', true)).toEqual('<a:_:827220205352255549>');
});
test('GIVEN static id in options object THEN returns "<:_:${id}>"', () => {
expect<`<:_:851461487498493952>`>(formatEmoji({ id: '851461487498493952' })).toEqual('<:_:851461487498493952>');
});
test('GIVEN static id in options object WITH animated explicitly false THEN returns "<:_:${id}>"', () => {
expect<`<:_:851461487498493952>`>(formatEmoji({ animated: false, id: '851461487498493952' })).toEqual(
'<:_:851461487498493952>',
);
});
test('GIVEN animated id in options object THEN returns "<a:_:${id}>"', () => {
expect<`<a:_:827220205352255549>`>(formatEmoji({ animated: true, id: '827220205352255549' })).toEqual(
'<a:_:827220205352255549>',
);
});
test('GIVEN static id and name in options object THEN returns "<:${name}:${id}>"', () => {
expect<`<:test:851461487498493952>`>(formatEmoji({ id: '851461487498493952', name: 'test' })).toEqual(
'<:test:851461487498493952>',
);
});
test('GIVEN static id and name WITH animated explicitly false THEN returns "<:${name}:${id}>"', () => {
expect<`<:test:851461487498493952>`>(
formatEmoji({ animated: false, id: '851461487498493952', name: 'test' }),
).toEqual('<:test:851461487498493952>');
});
test('GIVEN animated id and name THEN returns "<a:${name}:${id}>"', () => {
expect<`<a:test:827220205352255549>`>(
formatEmoji({ id: '827220205352255549', name: 'test', animated: true }),
).toEqual('<a:test:827220205352255549>');
});
});
describe('channelLink', () => {