@mkody/twitch-emoticons 2.9.6 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +530 -169
  2. package/dist/TwitchEmoticons.cjs +950 -0
  3. package/dist/TwitchEmoticons.esm.min.js +7 -0
  4. package/dist/TwitchEmoticons.esm.min.js.map +7 -0
  5. package/dist/TwitchEmoticons.min.js +2 -20
  6. package/dist/TwitchEmoticons.min.js.map +4 -4
  7. package/package.json +99 -72
  8. package/src/index.js +38 -12
  9. package/src/struct/BTTVEmote.js +72 -74
  10. package/src/struct/Channel.js +48 -48
  11. package/src/struct/Emote.js +71 -71
  12. package/src/struct/EmoteFetcher.js +358 -322
  13. package/src/struct/EmoteParser.js +95 -84
  14. package/src/struct/EmoteTypeMapper.js +9 -9
  15. package/src/struct/FFZEmote.js +91 -93
  16. package/src/struct/SevenTVEmote.js +88 -90
  17. package/src/struct/TwitchEmote.js +72 -71
  18. package/src/util/Collection.js +69 -55
  19. package/src/util/Constants.js +30 -30
  20. package/typings/index.d.cts +254 -0
  21. package/typings/index.d.ts +216 -99
  22. package/.jsdoc.json +0 -46
  23. package/.nvmrc +0 -1
  24. package/docs/BTTVEmote.html +0 -1532
  25. package/docs/Channel.html +0 -824
  26. package/docs/Collection.html +0 -798
  27. package/docs/Emote.html +0 -832
  28. package/docs/EmoteFetcher.html +0 -3741
  29. package/docs/EmoteParser.html +0 -1187
  30. package/docs/FFZEmote.html +0 -1686
  31. package/docs/SevenTVEmote.html +0 -1596
  32. package/docs/TwitchEmote.html +0 -1528
  33. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  34. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  35. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  36. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  37. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  38. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  39. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  40. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
  43. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  44. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  45. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  46. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  47. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
  48. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  49. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  50. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  51. package/docs/index.html +0 -233
  52. package/docs/scripts/collapse.js +0 -39
  53. package/docs/scripts/commonNav.js +0 -28
  54. package/docs/scripts/linenumber.js +0 -25
  55. package/docs/scripts/nav.js +0 -12
  56. package/docs/scripts/polyfill.js +0 -4
  57. package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  58. package/docs/scripts/prettify/lang-css.js +0 -2
  59. package/docs/scripts/prettify/prettify.js +0 -28
  60. package/docs/scripts/search.js +0 -99
  61. package/docs/struct_BTTVEmote.js.html +0 -162
  62. package/docs/struct_Channel.js.html +0 -132
  63. package/docs/struct_Emote.js.html +0 -159
  64. package/docs/struct_EmoteFetcher.js.html +0 -429
  65. package/docs/struct_EmoteParser.js.html +0 -172
  66. package/docs/struct_FFZEmote.js.html +0 -185
  67. package/docs/struct_SevenTVEmote.js.html +0 -180
  68. package/docs/struct_TwitchEmote.js.html +0 -159
  69. package/docs/styles/jsdoc.css +0 -776
  70. package/docs/styles/prettify.css +0 -80
  71. package/docs/util_Collection.js.html +0 -151
  72. package/eslint.config.mjs +0 -215
  73. package/jest.config.js +0 -198
  74. package/test/BTTV.test.js +0 -48
  75. package/test/FFZ.test.js +0 -71
  76. package/test/SevenTV.test.js +0 -71
  77. package/test/ToFromObject.test.js +0 -156
  78. package/test/Twitch.test.js +0 -64
  79. package/test/__snapshots__/ToFromObject.test.js.snap +0 -121
  80. package/test/other.test.js +0 -72
package/test/BTTV.test.js DELETED
@@ -1,48 +0,0 @@
1
- const { describe, expect, test } = require('@jest/globals');
2
- const { EmoteFetcher, EmoteParser, Collection } = require('../src/index.js');
3
-
4
- describe('Test BTTV emotes', () => {
5
- describe('Test global emotes', () => {
6
- const emoteFetcher = new EmoteFetcher();
7
- const emoteParser = new EmoteParser(emoteFetcher, {
8
- type: 'markdown',
9
- match: /:(.+?):/g
10
- });
11
-
12
- test('Execute fetchBTTVEmotes without any parameters', async() => {
13
- expect(await emoteFetcher.fetchBTTVEmotes()).toBeInstanceOf(Collection);
14
- });
15
-
16
- test('Get emote (SourPls)', () => {
17
- const emote = emoteFetcher.emotes.get('SourPls');
18
- expect(emote.toLink(2)).toBe('https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/3x.webp');
19
- });
20
-
21
- test('Parse string with emote (SourPls)', () => {
22
- const text = emoteParser.parse('This is a test string with :SourPls: in it.');
23
- expect(text).toBe('This is a test string with ![SourPls](https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/1x.webp "SourPls") in it.');
24
- });
25
- });
26
-
27
- describe('Test user emotes', () => {
28
- const emoteFetcher = new EmoteFetcher();
29
- const emoteParser = new EmoteParser(emoteFetcher, {
30
- type: 'markdown',
31
- match: /:(.+?):/g
32
- });
33
-
34
- test('Execute fetchBTTVEmotes with user ID', async() => {
35
- expect(await emoteFetcher.fetchBTTVEmotes(56648155)).toBeInstanceOf(Collection);
36
- });
37
-
38
- test('Get emote (tppUrn)', () => {
39
- const emote = emoteFetcher.emotes.get('tppUrn');
40
- expect(emote.toLink(2)).toBe('https://cdn.betterttv.net/emote/5f5f7d5f68d9d86c020e8672/3x.webp');
41
- });
42
-
43
- test('Parse string with emote (tppUrn)', () => {
44
- const text = emoteParser.parse('This is a test string with :tppUrn: in it.');
45
- expect(text).toBe('This is a test string with ![tppUrn](https://cdn.betterttv.net/emote/5f5f7d5f68d9d86c020e8672/1x.webp "tppUrn") in it.');
46
- });
47
- });
48
- });
package/test/FFZ.test.js DELETED
@@ -1,71 +0,0 @@
1
- const { describe, expect, test } = require('@jest/globals');
2
- const { EmoteFetcher, EmoteParser, Collection } = require('../src/index.js');
3
-
4
- describe('Test FFZ emotes', () => {
5
- describe('Test global emotes', () => {
6
- const emoteFetcher = new EmoteFetcher();
7
- const emoteParser = new EmoteParser(emoteFetcher, {
8
- type: 'markdown',
9
- match: /:(.+?):/g
10
- });
11
-
12
- test('Execute fetchFFZEmotes without any parameters', async() => {
13
- expect(await emoteFetcher.fetchFFZEmotes()).toBeInstanceOf(Collection);
14
- });
15
-
16
- test('Get emote (CatBag)', () => {
17
- const emote = emoteFetcher.emotes.get('CatBag');
18
- expect(emote.toLink(2)).toBe('https://cdn.frankerfacez.com/emote/25927/4');
19
- });
20
-
21
- test('Parse string with emote (CatBag)', () => {
22
- const text = emoteParser.parse('This is a test string with :CatBag: in it.');
23
- expect(text).toBe('This is a test string with ![CatBag](https://cdn.frankerfacez.com/emote/25927/1 "CatBag") in it.');
24
- });
25
- });
26
-
27
- describe('Test user emotes', () => {
28
- const emoteFetcher = new EmoteFetcher();
29
- const emoteParser = new EmoteParser(emoteFetcher, {
30
- type: 'markdown',
31
- match: /:(.+?):/g
32
- });
33
-
34
- test('Execute fetchFFZEmotes with user ID', async() => {
35
- expect(await emoteFetcher.fetchFFZEmotes(44317909)).toBeInstanceOf(Collection);
36
- });
37
-
38
- test('Get emote (5Head)', () => {
39
- const emote = emoteFetcher.emotes.get('5Head');
40
- expect(emote.toLink(2)).toBe('https://cdn.frankerfacez.com/emote/239504/4');
41
- });
42
-
43
- test('Parse string with emote (5Head)', () => {
44
- const text = emoteParser.parse('This is a test string with :5Head: in it.');
45
- expect(text).toBe('This is a test string with ![5Head](https://cdn.frankerfacez.com/emote/239504/1 "5Head") in it.');
46
- });
47
- });
48
-
49
- describe('Test animated and modifier emotes', () => {
50
- const emoteFetcher = new EmoteFetcher();
51
- const emoteParser = new EmoteParser(emoteFetcher, {
52
- type: 'markdown',
53
- match: /:(.+?):/g
54
- });
55
-
56
- test('Execute fetchFFZEmotes with user ID', async() => {
57
- expect(await emoteFetcher.fetchFFZEmotes(44317909)).toBeInstanceOf(Collection);
58
- });
59
-
60
- test('Get animated emote (MikuSway)', () => {
61
- const emote = emoteFetcher.emotes.get('MikuSway');
62
- expect(emote.toLink(2)).toBe('https://cdn.frankerfacez.com/emote/723102/animated/4.webp');
63
- });
64
-
65
- test('Parse string with emote (monkaEyes) and modifier (ffzHyper)', () => {
66
- const text = emoteParser.parse('This is a test string with :monkaEyes: :ffzHyper: in it.');
67
- // Note the double space: ffzHyper is removed but not the space before
68
- expect(text).toBe('This is a test string with ![monkaEyes](https://cdn.frankerfacez.com/emote/268204/1 "monkaEyes") in it.');
69
- });
70
- });
71
- });
@@ -1,71 +0,0 @@
1
- const { describe, expect, test } = require('@jest/globals');
2
- const { EmoteFetcher, EmoteParser, Collection } = require('../src/index.js');
3
-
4
- describe('Test 7TV emotes', () => {
5
- describe('Test global emotes (WEBP)', () => {
6
- const emoteFetcher = new EmoteFetcher();
7
- const emoteParser = new EmoteParser(emoteFetcher, {
8
- type: 'markdown',
9
- match: /:(.+?):/g
10
- });
11
-
12
- test('Execute fetchSevenTVEmotes with the WEBP format', async() => {
13
- expect(await emoteFetcher.fetchSevenTVEmotes(null, 'webp')).toBeInstanceOf(Collection);
14
- });
15
-
16
- test('Get emote (EZ)', () => {
17
- const emote = emoteFetcher.emotes.get('EZ');
18
- expect(emote.toLink(2)).toBe('https://cdn.7tv.app/emote/01GB4CK01800090V9B3D8CGEEX/3x.webp');
19
- });
20
-
21
- test('Parse string with emote (EZ)', () => {
22
- const text = emoteParser.parse('This is a test string with :EZ: in it.');
23
- expect(text).toBe('This is a test string with ![EZ](https://cdn.7tv.app/emote/01GB4CK01800090V9B3D8CGEEX/1x.webp "EZ") in it.');
24
- });
25
- });
26
-
27
- describe('Test global emotes (AVIF)', () => {
28
- const emoteFetcher = new EmoteFetcher();
29
- const emoteParser = new EmoteParser(emoteFetcher, {
30
- type: 'markdown',
31
- match: /:(.+?):/g
32
- });
33
-
34
- test('Execute fetchSevenTVEmotes with the AVIF format', async() => {
35
- expect(await emoteFetcher.fetchSevenTVEmotes(null, 'avif')).toBeInstanceOf(Collection);
36
- });
37
-
38
- test('Get emote (Clap)', () => {
39
- const emote = emoteFetcher.emotes.get('Clap');
40
- expect(emote.toLink(2)).toBe('https://cdn.7tv.app/emote/01GAM8EFQ00004MXFXAJYKA859/3x.avif');
41
- });
42
-
43
- test('Parse string with emote (Clap)', () => {
44
- const text = emoteParser.parse('This is a test string with :Clap: in it.');
45
- expect(text).toBe('This is a test string with ![Clap](https://cdn.7tv.app/emote/01GAM8EFQ00004MXFXAJYKA859/1x.avif "Clap") in it.');
46
- });
47
- });
48
-
49
- describe('Test user emotes', () => {
50
- const emoteFetcher = new EmoteFetcher();
51
- const emoteParser = new EmoteParser(emoteFetcher, {
52
- type: 'markdown',
53
- match: /:(.+?):/g
54
- });
55
-
56
- test('Execute fetchSevenTVEmotes with user ID', async() => {
57
- expect(await emoteFetcher.fetchSevenTVEmotes(44317909)).toBeInstanceOf(Collection);
58
- });
59
-
60
- // YABE was picked as it has been renamed from "fubukiYabe" on this channel
61
- test('Get emote (YABE)', () => {
62
- const emote = emoteFetcher.emotes.get('YABE');
63
- expect(emote.toLink(2)).toBe('https://cdn.7tv.app/emote/01FFNN7CG00009CAK0J14696HH/3x.webp');
64
- });
65
-
66
- test('Parse string with emote (YABE)', () => {
67
- const text = emoteParser.parse('This is a test string with :YABE: in it.');
68
- expect(text).toBe('This is a test string with ![YABE](https://cdn.7tv.app/emote/01FFNN7CG00009CAK0J14696HH/1x.webp "YABE") in it.');
69
- });
70
- });
71
- });
@@ -1,156 +0,0 @@
1
- const { describe, expect, test, beforeEach } = require('@jest/globals');
2
- const { env } = require('process');
3
- const { EmoteFetcher, EmoteParser } = require('../src/index.js');
4
-
5
- describe('Test toObject', () => {
6
- let emoteFetcher;
7
-
8
- beforeEach(() => {
9
- // Make a fresh EmoteFetcher object before each tests
10
- // This prevents surprises in case there's an emote name used in multiple sources
11
- emoteFetcher = new EmoteFetcher(env.TWITCH_ID, env.TWITCH_SECRET);
12
- });
13
-
14
- test('BTTV Global Emote', async() => {
15
- await emoteFetcher.fetchBTTVEmotes();
16
- expect(emoteFetcher.emotes.get('SourPls').toObject()).toMatchSnapshot();
17
- });
18
-
19
- test('BTTV User Emote', async() => {
20
- await emoteFetcher.fetchBTTVEmotes(56648155);
21
- expect(emoteFetcher.emotes.get('tppUrn').toObject()).toMatchSnapshot();
22
- });
23
-
24
- test('BTTV User Animated Emote', async() => {
25
- await emoteFetcher.fetchBTTVEmotes(56648155);
26
- expect(emoteFetcher.emotes.get('MODS').toObject()).toMatchSnapshot();
27
- });
28
-
29
- test('FFZ Global Emote', async() => {
30
- await emoteFetcher.fetchFFZEmotes();
31
- expect(emoteFetcher.emotes.get('CatBag').toObject()).toMatchSnapshot();
32
- });
33
-
34
- test('FFZ User Emote', async() => {
35
- await emoteFetcher.fetchFFZEmotes(13638332);
36
- expect(emoteFetcher.emotes.get('SanaeSip').toObject()).toMatchSnapshot();
37
- });
38
-
39
- test('FFZ User Animated Emote', async() => {
40
- await emoteFetcher.fetchFFZEmotes(44317909);
41
- expect(emoteFetcher.emotes.get('MikuSway').toObject()).toMatchSnapshot();
42
- });
43
-
44
- test('7TV Global Emote (AVIF)', async() => {
45
- await emoteFetcher.fetchSevenTVEmotes(null, 'avif');
46
- expect(emoteFetcher.emotes.get('EZ').toObject()).toMatchSnapshot();
47
- });
48
-
49
- test('7TV User Emote', async() => {
50
- await emoteFetcher.fetchSevenTVEmotes(44317909);
51
- // YABE was picked as it has been renamed from "fubukiYabe" on this channel
52
- expect(emoteFetcher.emotes.get('YABE').toObject()).toMatchSnapshot();
53
- });
54
-
55
- if (env.TWITCH_ID === undefined || env.TWITCH_SECRET === undefined
56
- || env.TWITCH_ID === '' || env.TWITCH_SECRET === '') {
57
- test.todo('Notice: Twitch client id/secret missing, not testing with Twitch emotes.');
58
- } else {
59
- test('Twitch Global Emote', async() => {
60
- await emoteFetcher.fetchTwitchEmotes();
61
- // Use inline to not fail when the environment variables are not set
62
- expect(emoteFetcher.emotes.get('Kappa').toObject()).toMatchInlineSnapshot(`
63
- {
64
- "animated": false,
65
- "channel_id": null,
66
- "code": "Kappa",
67
- "id": "25",
68
- "set": undefined,
69
- "type": "twitch",
70
- }
71
- `);
72
- });
73
-
74
- test('Twitch User Emote', async() => {
75
- await emoteFetcher.fetchTwitchEmotes(56648155);
76
- // Use inline to not fail when the environment variables are not set
77
- expect(emoteFetcher.emotes.get('tppD').toObject()).toMatchInlineSnapshot(`
78
- {
79
- "animated": false,
80
- "channel_id": 56648155,
81
- "code": "tppD",
82
- "id": "307609315",
83
- "set": undefined,
84
- "type": "twitch",
85
- }
86
- `);
87
- });
88
- }
89
- });
90
-
91
- describe('Test fromObject', () => {
92
- const emoteFetcher = new EmoteFetcher();
93
- const emoteParser = new EmoteParser(emoteFetcher, {
94
- type: 'markdown',
95
- match: /(\w+)+?/g
96
- });
97
-
98
- const emotes_obj = [
99
- {
100
- code: 'tppD',
101
- id: '307609315',
102
- channel_id: 56648155,
103
- animated: false,
104
- set: undefined,
105
- type: 'twitch'
106
- },
107
- {
108
- code: 'SourPls',
109
- id: '566ca38765dbbdab32ec0560',
110
- channel_id: null,
111
- animated: true,
112
- ownerName: null,
113
- type: 'bttv'
114
- },
115
- {
116
- code: 'modCheck',
117
- id: '60abf171870d317bef23d399',
118
- channel_id: 44317909,
119
- animated: true,
120
- sizes: ['1x.webp', '2x.webp', '3x.webp', '4x.webp'],
121
- ownerName: 'Laden',
122
- type: '7tv',
123
- imageType: 'webp'
124
- },
125
- {
126
- code: 'MikuSway',
127
- id: 723102,
128
- channel_id: 44317909,
129
- animated: true,
130
- sizes: ['1', '2', '4'],
131
- ownerName: 'brian6932',
132
- type: 'ffz',
133
- modifier: false
134
- }
135
- ];
136
-
137
- test('Execute fromObject', () => {
138
- expect(emoteFetcher.fromObject(emotes_obj)).toBeInstanceOf(Array);
139
- });
140
-
141
- test('Get emote (SourPls)', () => {
142
- const emote = emoteFetcher.emotes.get('SourPls');
143
- expect(emote.toLink()).toBe('https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/1x.webp');
144
- });
145
-
146
- test('Parse string with emotes (tppD, SourPls, modCheck, MikuSway)', () => {
147
- expect(emoteParser.parse('tppD SourPls modCheck MikuSway')).toBe(
148
- [
149
- '![tppD](https://static-cdn.jtvnw.net/emoticons/v2/307609315/default/dark/1.0 "tppD")',
150
- '![SourPls](https://cdn.betterttv.net/emote/566ca38765dbbdab32ec0560/1x.webp "SourPls")',
151
- '![modCheck](https://cdn.7tv.app/emote/60abf171870d317bef23d399/1x.webp "modCheck")',
152
- '![MikuSway](https://cdn.frankerfacez.com/emote/723102/animated/1.webp "MikuSway")'
153
- ].join(' ')
154
- );
155
- });
156
- });
@@ -1,64 +0,0 @@
1
- const { describe, expect, test } = require('@jest/globals');
2
- const { env } = require('process');
3
- const { EmoteFetcher, EmoteParser, Collection } = require('../src/index.js');
4
-
5
- describe('Test Twitch emotes', () => {
6
- test('Test failing when environment variables are not set', () => {
7
- const emoteFetcher = new EmoteFetcher();
8
-
9
- expect(() => {
10
- emoteFetcher.fetchTwitchEmotes();
11
- }).toThrow(
12
- new Error('Client id or client secret not provided.')
13
- );
14
- });
15
-
16
- if (env.TWITCH_ID === undefined || env.TWITCH_SECRET === undefined
17
- || env.TWITCH_ID === '' || env.TWITCH_SECRET === '') {
18
- test.todo('Notice: Twitch client id/secret missing, not testing fetching and parsing.');
19
- } else {
20
- describe('Test global emotes', () => {
21
- const emoteFetcher = new EmoteFetcher(env.TWITCH_ID, env.TWITCH_SECRET);
22
- const emoteParser = new EmoteParser(emoteFetcher, {
23
- type: 'markdown',
24
- match: /:(.+?):/g
25
- });
26
-
27
- test('Execute fetchTwitchEmotes without any parameters', async() => {
28
- expect(await emoteFetcher.fetchTwitchEmotes()).toBeInstanceOf(Collection);
29
- });
30
-
31
- test('Get emote (Kappa)', () => {
32
- const emote = emoteFetcher.emotes.get('Kappa');
33
- expect(emote.toLink(2)).toBe('https://static-cdn.jtvnw.net/emoticons/v2/25/default/dark/3.0');
34
- });
35
-
36
- test('Parse string with emote (CoolCat)', () => {
37
- const text = emoteParser.parse('This is a test string with :CoolCat: in it.');
38
- expect(text).toBe('This is a test string with ![CoolCat](https://static-cdn.jtvnw.net/emoticons/v2/58127/default/dark/1.0 "CoolCat") in it.');
39
- });
40
- });
41
-
42
- describe('Test user emotes', () => {
43
- const emoteFetcher = new EmoteFetcher(env.TWITCH_ID, env.TWITCH_SECRET);
44
- const emoteParser = new EmoteParser(emoteFetcher, {
45
- type: 'markdown',
46
- match: /:(.+?):/g
47
- });
48
-
49
- test('Execute fetchTwitchEmotes with user ID', async() => {
50
- expect(await emoteFetcher.fetchTwitchEmotes(56648155)).toBeInstanceOf(Collection);
51
- });
52
-
53
- test('Get emote (tppD)', () => {
54
- const emote = emoteFetcher.emotes.get('tppD');
55
- expect(emote.toLink(2)).toBe('https://static-cdn.jtvnw.net/emoticons/v2/307609315/default/dark/3.0');
56
- });
57
-
58
- test('Parse string with emote (tppD)', () => {
59
- const text = emoteParser.parse('This is a test string with :tppD: in it.');
60
- expect(text).toBe('This is a test string with ![tppD](https://static-cdn.jtvnw.net/emoticons/v2/307609315/default/dark/1.0 "tppD") in it.');
61
- });
62
- });
63
- }
64
- });
@@ -1,121 +0,0 @@
1
- // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2
-
3
- exports[`Test toObject 7TV Global Emote (AVIF) 1`] = `
4
- {
5
- "animated": false,
6
- "channel_id": null,
7
- "code": "EZ",
8
- "id": "01GB4CK01800090V9B3D8CGEEX",
9
- "imageType": "avif",
10
- "ownerName": "TrippyColour",
11
- "sizes": [
12
- "1x.avif",
13
- "2x.avif",
14
- "3x.avif",
15
- "4x.avif",
16
- ],
17
- "type": "7tv",
18
- }
19
- `;
20
-
21
- exports[`Test toObject 7TV User Emote 1`] = `
22
- {
23
- "animated": true,
24
- "channel_id": 44317909,
25
- "code": "YABE",
26
- "id": "01FFNN7CG00009CAK0J14696HH",
27
- "imageType": "webp",
28
- "ownerName": "jenji333",
29
- "sizes": [
30
- "1x.webp",
31
- "2x.webp",
32
- "3x.webp",
33
- "4x.webp",
34
- ],
35
- "type": "7tv",
36
- }
37
- `;
38
-
39
- exports[`Test toObject BTTV Global Emote 1`] = `
40
- {
41
- "animated": true,
42
- "channel_id": null,
43
- "code": "SourPls",
44
- "id": "566ca38765dbbdab32ec0560",
45
- "ownerName": null,
46
- "type": "bttv",
47
- }
48
- `;
49
-
50
- exports[`Test toObject BTTV User Animated Emote 1`] = `
51
- {
52
- "animated": true,
53
- "channel_id": 56648155,
54
- "code": "MODS",
55
- "id": "5f2c4f9e65fe924464ef6d61",
56
- "ownerName": "bearrrr_",
57
- "type": "bttv",
58
- }
59
- `;
60
-
61
- exports[`Test toObject BTTV User Emote 1`] = `
62
- {
63
- "animated": false,
64
- "channel_id": 56648155,
65
- "code": "tppUrn",
66
- "id": "5f5f7d5f68d9d86c020e8672",
67
- "ownerName": null,
68
- "type": "bttv",
69
- }
70
- `;
71
-
72
- exports[`Test toObject FFZ Global Emote 1`] = `
73
- {
74
- "animated": false,
75
- "channel_id": null,
76
- "code": "CatBag",
77
- "id": 25927,
78
- "modifier": false,
79
- "ownerName": "wolsk",
80
- "sizes": [
81
- "1",
82
- "2",
83
- "4",
84
- ],
85
- "type": "ffz",
86
- }
87
- `;
88
-
89
- exports[`Test toObject FFZ User Animated Emote 1`] = `
90
- {
91
- "animated": true,
92
- "channel_id": 44317909,
93
- "code": "MikuSway",
94
- "id": 723102,
95
- "modifier": false,
96
- "ownerName": "brian6932",
97
- "sizes": [
98
- "1",
99
- "2",
100
- "4",
101
- ],
102
- "type": "ffz",
103
- }
104
- `;
105
-
106
- exports[`Test toObject FFZ User Emote 1`] = `
107
- {
108
- "animated": false,
109
- "channel_id": 13638332,
110
- "code": "SanaeSip",
111
- "id": 305078,
112
- "modifier": false,
113
- "ownerName": "shizuka_natsume",
114
- "sizes": [
115
- "1",
116
- "2",
117
- "4",
118
- ],
119
- "type": "ffz",
120
- }
121
- `;
@@ -1,72 +0,0 @@
1
- const { describe, expect, test } = require('@jest/globals');
2
- const { Emote, EmoteFetcher, EmoteParser } = require('../src/index.js');
3
-
4
- describe('Emote class', () => {
5
- test('Base Emote class should not be used by itself', () => {
6
- expect(() => {
7
- // eslint-disable-next-line no-unused-vars
8
- const emote = new Emote();
9
- }).toThrow(
10
- new Error('Base Emote class cannot be used')
11
- );
12
- });
13
- });
14
-
15
- describe('EmoteParser\'s _validateOptions', () => {
16
- const fetcher = new EmoteFetcher();
17
-
18
- test('Should not throw on valid options', () => {
19
- expect(() => {
20
- // eslint-disable-next-line no-unused-vars
21
- const parser = new EmoteParser(fetcher, {
22
- template: '![{name}]({link} "{name}")',
23
- type: 'markdown',
24
- match: /:(.+?):/g
25
- });
26
- }).not.toThrow();
27
- });
28
-
29
- test('Should throw on invalid template', () => {
30
- expect(() => {
31
- // eslint-disable-next-line no-unused-vars
32
- const parser = new EmoteParser(fetcher, {
33
- template: () => { return 'test'; }
34
- });
35
- }).toThrow(
36
- new TypeError('Template must be a string')
37
- );
38
- });
39
-
40
- test('Should throw on invalid type', () => {
41
- expect(() => {
42
- // eslint-disable-next-line no-unused-vars
43
- const parser = new EmoteParser(fetcher, {
44
- type: 'invalid-type'
45
- });
46
- }).toThrow(
47
- new TypeError('Parse type must be one of `markdown`, `html`, `bbcode`, or `plain`')
48
- );
49
- });
50
-
51
- test('Should throw when not using a global regex', () => {
52
- expect(() => {
53
- // eslint-disable-next-line no-unused-vars
54
- const parser = new EmoteParser(fetcher, {
55
- match: /:(.+?):/
56
- });
57
- }).toThrow(
58
- new TypeError('Match must be a global RegExp.')
59
- );
60
- });
61
-
62
- test('Should throw when not using a regex object', () => {
63
- expect(() => {
64
- // eslint-disable-next-line no-unused-vars
65
- const parser = new EmoteParser(fetcher, {
66
- match: 'not-a-regex'
67
- });
68
- }).toThrow(
69
- new TypeError('Match must be a global RegExp.')
70
- );
71
- });
72
- });