@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.
- package/README.md +530 -169
- package/dist/TwitchEmoticons.cjs +950 -0
- package/dist/TwitchEmoticons.esm.min.js +7 -0
- package/dist/TwitchEmoticons.esm.min.js.map +7 -0
- package/dist/TwitchEmoticons.min.js +2 -20
- package/dist/TwitchEmoticons.min.js.map +4 -4
- package/package.json +99 -72
- package/src/index.js +38 -12
- package/src/struct/BTTVEmote.js +72 -74
- package/src/struct/Channel.js +48 -48
- package/src/struct/Emote.js +71 -71
- package/src/struct/EmoteFetcher.js +358 -322
- package/src/struct/EmoteParser.js +95 -84
- package/src/struct/EmoteTypeMapper.js +9 -9
- package/src/struct/FFZEmote.js +91 -93
- package/src/struct/SevenTVEmote.js +88 -90
- package/src/struct/TwitchEmote.js +72 -71
- package/src/util/Collection.js +69 -55
- package/src/util/Constants.js +30 -30
- package/typings/index.d.cts +254 -0
- package/typings/index.d.ts +216 -99
- package/.jsdoc.json +0 -46
- package/.nvmrc +0 -1
- package/docs/BTTVEmote.html +0 -1532
- package/docs/Channel.html +0 -824
- package/docs/Collection.html +0 -798
- package/docs/Emote.html +0 -832
- package/docs/EmoteFetcher.html +0 -3741
- package/docs/EmoteParser.html +0 -1187
- package/docs/FFZEmote.html +0 -1686
- package/docs/SevenTVEmote.html +0 -1596
- package/docs/TwitchEmote.html +0 -1528
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +0 -978
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +0 -1049
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +0 -233
- package/docs/scripts/collapse.js +0 -39
- package/docs/scripts/commonNav.js +0 -28
- package/docs/scripts/linenumber.js +0 -25
- package/docs/scripts/nav.js +0 -12
- package/docs/scripts/polyfill.js +0 -4
- package/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/docs/scripts/prettify/lang-css.js +0 -2
- package/docs/scripts/prettify/prettify.js +0 -28
- package/docs/scripts/search.js +0 -99
- package/docs/struct_BTTVEmote.js.html +0 -162
- package/docs/struct_Channel.js.html +0 -132
- package/docs/struct_Emote.js.html +0 -159
- package/docs/struct_EmoteFetcher.js.html +0 -429
- package/docs/struct_EmoteParser.js.html +0 -172
- package/docs/struct_FFZEmote.js.html +0 -185
- package/docs/struct_SevenTVEmote.js.html +0 -180
- package/docs/struct_TwitchEmote.js.html +0 -159
- package/docs/styles/jsdoc.css +0 -776
- package/docs/styles/prettify.css +0 -80
- package/docs/util_Collection.js.html +0 -151
- package/eslint.config.mjs +0 -215
- package/jest.config.js +0 -198
- package/test/BTTV.test.js +0 -48
- package/test/FFZ.test.js +0 -71
- package/test/SevenTV.test.js +0 -71
- package/test/ToFromObject.test.js +0 -156
- package/test/Twitch.test.js +0 -64
- package/test/__snapshots__/ToFromObject.test.js.snap +0 -121
- 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  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  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  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  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  in it.');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
package/test/SevenTV.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 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  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  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  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
|
-
'',
|
|
150
|
-
'',
|
|
151
|
-
'',
|
|
152
|
-
''
|
|
153
|
-
].join(' ')
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
});
|
package/test/Twitch.test.js
DELETED
|
@@ -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  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  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
|
-
`;
|
package/test/other.test.js
DELETED
|
@@ -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: '',
|
|
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
|
-
});
|