-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Expand file tree
/
Copy pathemoji.test.ts
More file actions
56 lines (47 loc) · 1.52 KB
/
emoji.test.ts
File metadata and controls
56 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { DiscordSnowflake } from '@sapphire/snowflake';
import type { APIEmoji, APIUser } from 'discord-api-types/v10';
import { describe, expect, test } from 'vitest';
import { Emoji } from '../src/emojis/Emoji.js';
import { kPatch } from '../src/utils/symbols.js';
describe('Emoji structure', () => {
const user: APIUser = {
id: '1',
username: 'username',
discriminator: '0000',
global_name: 'djs.structures.user.global_name',
avatar: 'djs.structures.user.avatar',
};
const data: APIEmoji = {
id: '1',
name: 'name',
roles: ['1', '2', '3'],
user,
require_colons: true,
managed: true,
animated: true,
available: true,
};
const instance = new Emoji(data);
test('Emoji has all properties', () => {
expect(instance.id).toBe(data.id);
expect(instance.name).toBe(data.name);
expect(instance.requireColons).toBe(data.require_colons);
expect(instance.managed).toBe(data.managed);
expect(instance.animated).toBe(data.animated);
expect(instance.available).toBe(data.available);
const createdTimestamp = DiscordSnowflake.timestampFrom(data.id!);
expect(instance.createdTimestamp).toBe(createdTimestamp);
expect(instance.createdAt!.valueOf()).toBe(createdTimestamp);
});
test('toJSON() is accurate', () => {
expect(instance.toJSON()).toStrictEqual(data);
});
test('Patching the Emoji works in place', () => {
const patched = instance[kPatch]({
available: false,
});
expect(patched.available).toBeFalsy();
expect(patched.toJSON()).not.toEqual(data);
expect(patched).toBe(instance);
});
});