2021-09-25 01:17:40 -04:00
|
|
|
import 'dart:convert';
|
2022-07-31 18:23:54 -04:00
|
|
|
|
2021-09-25 01:17:40 -04:00
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
|
import 'package:frosty/models/user.dart';
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
test('Twitch user should parse', () {
|
|
|
|
|
const sampleUser = '''
|
|
|
|
|
{
|
|
|
|
|
"id":"88888888",
|
|
|
|
|
"login":"bob",
|
|
|
|
|
"display_name":"Bob",
|
|
|
|
|
"type":"random type",
|
|
|
|
|
"broadcaster_type":"streamer",
|
|
|
|
|
"description":"random description",
|
|
|
|
|
"profile_image_url":"https://static-cdn.jtvnw.net/user-default-pictures-uv/ead5c8b2-a4c9-4724-b1dd-9f00b46cbd3d-profile_image-300x300.png",
|
|
|
|
|
"offline_image_url":"",
|
|
|
|
|
"view_count":94,
|
|
|
|
|
"created_at":"2013-09-25T00:32:05Z"
|
|
|
|
|
}
|
|
|
|
|
''';
|
|
|
|
|
|
|
|
|
|
final decoded = jsonDecode(sampleUser);
|
|
|
|
|
final user = UserTwitch.fromJson(decoded);
|
|
|
|
|
|
|
|
|
|
expect(user.id, '88888888');
|
|
|
|
|
expect(user.login, 'bob');
|
|
|
|
|
expect(user.displayName, 'Bob');
|
2023-10-22 18:38:32 -04:00
|
|
|
expect(
|
|
|
|
|
user.profileImageUrl,
|
|
|
|
|
'https://static-cdn.jtvnw.net/user-default-pictures-uv/ead5c8b2-a4c9-4724-b1dd-9f00b46cbd3d-profile_image-300x300.png',
|
|
|
|
|
);
|
2021-09-25 01:17:40 -04:00
|
|
|
});
|
|
|
|
|
}
|