mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
feat: Add channel & message URL formatters (#8371)
This commit is contained in:
@@ -3,6 +3,7 @@ import { describe, test, expect, vitest } from 'vitest';
|
||||
import {
|
||||
blockQuote,
|
||||
bold,
|
||||
channelLink,
|
||||
channelMention,
|
||||
codeBlock,
|
||||
Faces,
|
||||
@@ -11,6 +12,7 @@ import {
|
||||
hyperlink,
|
||||
inlineCode,
|
||||
italic,
|
||||
messageLink,
|
||||
quote,
|
||||
roleMention,
|
||||
spoiler,
|
||||
@@ -150,6 +152,34 @@ describe('Message formatters', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('channelLink', () => {
|
||||
test('GIVEN channelId THEN returns "https://discord.com/channels/@me/${channelId}"', () => {
|
||||
expect<'https://discord.com/channels/@me/123456789012345678'>(channelLink('123456789012345678')).toEqual(
|
||||
'https://discord.com/channels/@me/123456789012345678',
|
||||
);
|
||||
});
|
||||
|
||||
test('GIVEN channelId WITH guildId THEN returns "https://discord.com/channels/${guildId}/${channelId}"', () => {
|
||||
expect<'https://discord.com/channels/987654321987654/123456789012345678'>(
|
||||
channelLink('123456789012345678', '987654321987654'),
|
||||
).toEqual('https://discord.com/channels/987654321987654/123456789012345678');
|
||||
});
|
||||
});
|
||||
|
||||
describe('messageLink', () => {
|
||||
test('GIVEN channelId AND messageId THEN returns "https://discord.com/channels/@me/${channelId}/${messageId}"', () => {
|
||||
expect<'https://discord.com/channels/@me/123456789012345678/102938475657483'>(
|
||||
messageLink('123456789012345678', '102938475657483'),
|
||||
).toEqual('https://discord.com/channels/@me/123456789012345678/102938475657483');
|
||||
});
|
||||
|
||||
test('GIVEN channelId AND messageId WITH guildId THEN returns "https://discord.com/channels/${guildId}/${channelId}/${messageId}"', () => {
|
||||
expect<'https://discord.com/channels/987654321987654/123456789012345678/102938475657483'>(
|
||||
messageLink('123456789012345678', '102938475657483', '987654321987654'),
|
||||
).toEqual('https://discord.com/channels/987654321987654/123456789012345678/102938475657483');
|
||||
});
|
||||
});
|
||||
|
||||
describe('time', () => {
|
||||
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
|
||||
vitest.useFakeTimers();
|
||||
|
||||
Reference in New Issue
Block a user