39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:ikar/core/utils/ip_lookup_service.dart';
|
|
import 'package:ikar/frontend/screens/profile/devices_screen.dart';
|
|
|
|
void main() {
|
|
test('devices screen can be constructed with the protected lookup flow', () {
|
|
expect(const DevicesScreen(), isA<DevicesScreen>());
|
|
});
|
|
|
|
test('normalizes an ipwho.is response', () {
|
|
final details = IpLookupDetails.fromIpWhoIs({
|
|
'success': true,
|
|
'city': 'Moscow',
|
|
'country': 'Russia',
|
|
'connection': {'asn': 64500, 'org': 'Example Org', 'isp': 'Example ISP'},
|
|
'security': {'mobile': true, 'proxy': false},
|
|
'timezone': {'id': 'Europe/Moscow'},
|
|
});
|
|
|
|
expect(details.city, 'Moscow');
|
|
expect(details.country, 'Russia');
|
|
expect(details.isp, 'Example ISP');
|
|
expect(details.network, 'AS64500 Example Org');
|
|
expect(details.mobile, isTrue);
|
|
expect(details.proxy, isFalse);
|
|
expect(details.timezone, 'Europe/Moscow');
|
|
});
|
|
|
|
test('rejects a failed provider response', () {
|
|
expect(
|
|
() => IpLookupDetails.fromIpWhoIs({
|
|
'success': false,
|
|
'message': 'Invalid IP',
|
|
}),
|
|
throwsFormatException,
|
|
);
|
|
});
|
|
}
|