@mkody/twitch-emoticons 2.9.3 → 2.9.5
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/.jsdoc.json +12 -5
- package/.nvmrc +1 -1
- package/dist/TwitchEmoticons.min.js +11 -11
- package/dist/TwitchEmoticons.min.js.map +4 -4
- package/docs/BTTVEmote.html +72 -72
- package/docs/Channel.html +19 -19
- package/docs/Collection.html +25 -25
- package/docs/Emote.html +63 -33
- package/docs/EmoteFetcher.html +426 -366
- package/docs/EmoteParser.html +378 -3
- package/docs/FFZEmote.html +82 -82
- package/docs/SevenTVEmote.html +77 -77
- package/docs/TwitchEmote.html +68 -68
- package/docs/index.html +3 -3
- package/docs/struct_BTTVEmote.js.html +2 -2
- package/docs/struct_Channel.js.html +2 -2
- package/docs/struct_Emote.js.html +3 -2
- package/docs/struct_EmoteFetcher.js.html +4 -2
- package/docs/struct_EmoteParser.js.html +22 -3
- package/docs/struct_FFZEmote.js.html +2 -2
- package/docs/struct_SevenTVEmote.js.html +2 -2
- package/docs/struct_TwitchEmote.js.html +2 -2
- package/docs/util_Collection.js.html +4 -3
- package/package.json +14 -14
- package/src/struct/Emote.js +1 -0
- package/src/struct/EmoteFetcher.js +2 -0
- package/src/struct/EmoteParser.js +20 -1
- package/src/util/Collection.js +1 -0
- package/test/SevenTV.test.js +4 -4
- package/test/__snapshots__/ToFromObject.test.js.snap +1 -1
- package/test/other.test.js +60 -1
- package/typings/index.d.ts +4 -4
- package/docs/SevenTV.html +0 -1191
package/test/other.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { describe, expect, test } = require('@jest/globals');
|
|
2
|
-
const { Emote } = require('../src/index.js');
|
|
2
|
+
const { Emote, EmoteFetcher, EmoteParser } = require('../src/index.js');
|
|
3
3
|
|
|
4
4
|
describe('Emote class', () => {
|
|
5
5
|
test('Base Emote class should not be used by itself', () => {
|
|
@@ -11,3 +11,62 @@ describe('Emote class', () => {
|
|
|
11
11
|
);
|
|
12
12
|
});
|
|
13
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
|
+
});
|
package/typings/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare module '@mkody/twitch-emoticons' {
|
|
|
45
45
|
fetcher: EmoteFetcher,
|
|
46
46
|
options: {
|
|
47
47
|
template?: string,
|
|
48
|
-
type?:
|
|
48
|
+
type?: 'html' | 'markdown' | 'bbcode' | 'plain',
|
|
49
49
|
match?: RegExp
|
|
50
50
|
}
|
|
51
51
|
);
|
|
@@ -117,8 +117,8 @@ declare module '@mkody/twitch-emoticons' {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export class Collection<K, V> extends Map<K, V> {
|
|
120
|
-
public find(propOrFunc: string | ((item:
|
|
121
|
-
public filter(func: (item:
|
|
122
|
-
public map(func: (item:
|
|
120
|
+
public find(propOrFunc: string | ((item: V, index: number, coll: this) => boolean), value?: any): V;
|
|
121
|
+
public filter(func: (item: V, index: number, coll: this) => boolean): Collection<K, V>;
|
|
122
|
+
public map(func: (item: V, index: number, coll: this) => any): Array<any>;
|
|
123
123
|
}
|
|
124
124
|
}
|