mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
feat: add email and phoneNumber formatters (#11050)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,8 @@ import {
|
||||
underline,
|
||||
unorderedList,
|
||||
userMention,
|
||||
email,
|
||||
phoneNumber,
|
||||
} from '../src/index.js';
|
||||
|
||||
describe('Message formatters', () => {
|
||||
@@ -335,6 +337,33 @@ describe('Message formatters', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('email', () => {
|
||||
test('GIVEN an email THEN returns "<[email]>"', () => {
|
||||
expect<'<test@example.com>'>(email('test@example.com')).toEqual('<test@example.com>');
|
||||
});
|
||||
|
||||
test('GIVEN an email AND headers THEN returns "<[email]?[headers]>"', () => {
|
||||
expect<`<test@example.com?${string}>`>(email('test@example.com', { subject: 'Hello', body: 'World' })).toEqual(
|
||||
'<test@example.com?subject=Hello&body=World>',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('phoneNumber', () => {
|
||||
test('GIVEN a phone number with + THEN returns "<[phoneNumber]>"', () => {
|
||||
expect<'<+1234567890>'>(phoneNumber('+1234567890')).toEqual('<+1234567890>');
|
||||
});
|
||||
|
||||
test('GIVEN a phone number without + THEN throws', () => {
|
||||
expect(() =>
|
||||
phoneNumber(
|
||||
// @ts-expect-error - Invalid input
|
||||
'1234567890',
|
||||
),
|
||||
).toThrowError();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Faces', () => {
|
||||
test('GIVEN Faces.Shrug THEN returns "¯\\_(ツ)_/¯"', () => {
|
||||
expect<'¯\\_(ツ)_/¯'>(Faces.Shrug).toEqual('¯\\_(ツ)_/¯');
|
||||
|
||||
Reference in New Issue
Block a user