mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
feat!: Support animated WebP (#10911)
* feat: support animated WebP * refactor: change the rest * fix: remove redundant code
This commit is contained in:
@@ -23,7 +23,7 @@ test('avatar default', () => {
|
||||
});
|
||||
|
||||
test('avatar dynamic-animated', () => {
|
||||
expect(cdn.avatar(id, animatedHash)).toEqual(`${baseCDN}/avatars/${id}/${animatedHash}.gif`);
|
||||
expect(cdn.avatar(id, animatedHash)).toEqual(`${baseCDN}/avatars/${id}/${animatedHash}.webp?animated=true`);
|
||||
});
|
||||
|
||||
test('avatar dynamic-not-animated', () => {
|
||||
@@ -50,28 +50,16 @@ test('discoverySplash default', () => {
|
||||
expect(cdn.discoverySplash(id, hash)).toEqual(`${baseCDN}/discovery-splashes/${id}/${hash}.webp`);
|
||||
});
|
||||
|
||||
test('emoji static', () => {
|
||||
expect(cdn.emoji(id, false)).toEqual(`${baseCDN}/emojis/${id}.webp`);
|
||||
});
|
||||
|
||||
test('emoji static with JPG extension', () => {
|
||||
expect(cdn.emoji(id, false, { extension: 'jpg' })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
});
|
||||
|
||||
test('emoji static with JPG extension with force static', () => {
|
||||
expect(cdn.emoji(id, false, { extension: 'jpg', forceStatic: true })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
test('emoji', () => {
|
||||
expect(cdn.emoji(id)).toEqual(`${baseCDN}/emojis/${id}.webp`);
|
||||
});
|
||||
|
||||
test('emoji animated', () => {
|
||||
expect(cdn.emoji(id, true)).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
expect(cdn.emoji(id, { animated: true })).toEqual(`${baseCDN}/emojis/${id}.webp?animated=true`);
|
||||
});
|
||||
|
||||
test('emoji animated with JPG extension', () => {
|
||||
expect(cdn.emoji(id, true, { extension: 'jpg' })).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
});
|
||||
|
||||
test('emoji animated with JPG extension with force static', () => {
|
||||
expect(cdn.emoji(id, true, { extension: 'jpg', forceStatic: true })).toEqual(`${baseCDN}/emojis/${id}.jpg`);
|
||||
test('emoji with GIF format', () => {
|
||||
expect(cdn.emoji(id, { extension: 'gif' })).toEqual(`${baseCDN}/emojis/${id}.gif`);
|
||||
});
|
||||
|
||||
test('guildMemberAvatar default', () => {
|
||||
@@ -80,7 +68,7 @@ test('guildMemberAvatar default', () => {
|
||||
|
||||
test('guildMemberAvatar dynamic-animated', () => {
|
||||
expect(cdn.guildMemberAvatar(id, id, animatedHash)).toEqual(
|
||||
`${baseCDN}/guilds/${id}/users/${id}/avatars/${animatedHash}.gif`,
|
||||
`${baseCDN}/guilds/${id}/users/${id}/avatars/${animatedHash}.webp?animated=true`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -94,7 +82,7 @@ test('guildMemberBanner default', () => {
|
||||
|
||||
test('guildMemberBanner dynamic-animated', () => {
|
||||
expect(cdn.guildMemberBanner(id, id, animatedHash)).toEqual(
|
||||
`${baseCDN}/guilds/${id}/users/${id}/banners/${animatedHash}.gif`,
|
||||
`${baseCDN}/guilds/${id}/users/${id}/banners/${animatedHash}.webp?animated=true`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -111,7 +99,7 @@ test('icon default', () => {
|
||||
});
|
||||
|
||||
test('icon dynamic-animated', () => {
|
||||
expect(cdn.icon(id, animatedHash)).toEqual(`${baseCDN}/icons/${id}/${animatedHash}.gif`);
|
||||
expect(cdn.icon(id, animatedHash)).toEqual(`${baseCDN}/icons/${id}/${animatedHash}.webp?animated=true`);
|
||||
});
|
||||
|
||||
test('icon dynamic-not-animated', () => {
|
||||
@@ -157,5 +145,7 @@ test('makeURL throws on invalid extension', () => {
|
||||
});
|
||||
|
||||
test('makeURL valid size', () => {
|
||||
expect(cdn.avatar(id, animatedHash, { size: 512 })).toEqual(`${baseCDN}/avatars/${id}/${animatedHash}.gif?size=512`);
|
||||
expect(cdn.avatar(id, animatedHash, { size: 512 })).toEqual(
|
||||
`${baseCDN}/avatars/${id}/${animatedHash}.webp?animated=true&size=512`,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user