Migrate 7TV emotes to V3 API (#287)

* Migrate 7TV global emotes to V3 API

* Migrate 7TV channel emotes to V3 API
This commit is contained in:
Tommy Chow 2023-11-01 13:34:21 -04:00 • committed by GitHub
parent 26c5bb2437
commit a981cec250
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 178 deletions

View file

@ -198,153 +198,4 @@ void main() {
expect(emote.urls.url4x, '//cdn.frankerfacez.com/emote/27081/4');
});
});
group('7TV', () {
test('global emote should parse correctly', () {
const sampleGlobal7TVEmote = '''
{
"id": "603ca884faf3a00014dff0ab",
"name": "gachiBASS",
"owner": null,
"visibility": 2,
"visibility_simple": [
"GLOBAL"
],
"mime": "image/gif",
"status": 3,
"tags": [
],
"width": [
32,
48,
76,
128
],
"height": [
32,
48,
76,
128
],
"urls": [
[
"1",
"https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/1x"
],
[
"2",
"https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/2x"
],
[
"3",
"https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/3x"
],
[
"4",
"https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/4x"
]
]
}
''';
final json = jsonDecode(sampleGlobal7TVEmote);
final emote = Emote7TV.fromJson(json);
expect(emote.name, 'gachiBASS');
expect(emote.visibilitySimple, ['GLOBAL']);
expect(emote.width, [32, 48, 76, 128]);
expect(emote.height, [32, 48, 76, 128]);
final urls = [
['1', 'https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/1x'],
['2', 'https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/2x'],
['3', 'https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/3x'],
['4', 'https://cdn.7tv.app/emote/603ca884faf3a00014dff0ab/4x'],
];
expect(emote.urls, urls);
});
test('channel emote should parse correctly', () {
const sampleEmote = '''
{
"id": "603caea243b9e100141caf4f",
"name": "TrollDespair",
"owner": {
"id": "603cae2496832ffa78c758cd",
"twitch_id": "",
"login": "swyfty_",
"display_name": "swyfty_",
"role": {
"id": "000000000000000000000000",
"name": "",
"position": 0,
"color": 0,
"allowed": 523,
"denied": 0,
"default": true
}
},
"visibility": 0,
"visibility_simple": [
],
"mime": "image/png",
"status": 3,
"tags": [
],
"width": [
32,
48,
76,
128
],
"height": [
32,
48,
76,
128
],
"urls": [
[
"1",
"https://cdn.7tv.app/emote/603caea243b9e100141caf4f/1x"
],
[
"2",
"https://cdn.7tv.app/emote/603caea243b9e100141caf4f/2x"
],
[
"3",
"https://cdn.7tv.app/emote/603caea243b9e100141caf4f/3x"
],
[
"4",
"https://cdn.7tv.app/emote/603caea243b9e100141caf4f/4x"
]
]
}
''';
final json = jsonDecode(sampleEmote);
final emote = Emote7TV.fromJson(json);
expect(emote.name, 'TrollDespair');
expect(emote.visibilitySimple, []);
expect(emote.width, [32, 48, 76, 128]);
expect(emote.height, [32, 48, 76, 128]);
final urls = [
['1', 'https://cdn.7tv.app/emote/603caea243b9e100141caf4f/1x'],
['2', 'https://cdn.7tv.app/emote/603caea243b9e100141caf4f/2x'],
['3', 'https://cdn.7tv.app/emote/603caea243b9e100141caf4f/3x'],
['4', 'https://cdn.7tv.app/emote/603caea243b9e100141caf4f/4x'],
];
expect(emote.urls, urls);
});
});
}