89 lines
2.7 KiB
Dart
89 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
|
|
|
import 'package:sxchnge_theme/sxchnge_theme.dart';
|
|
|
|
import 'package:sxchnge_app/kyc/limits.dart';
|
|
|
|
import 'package:sxchnge_app/generated/i18n/app_localizations.dart';
|
|
|
|
class Service implements LimitsService {
|
|
Service(this.row);
|
|
final VisibleLimit row;
|
|
@override
|
|
Future<Limits> fetch() async =>
|
|
Limits(tier: AccountTier.basic, rows: [row], simulated: true);
|
|
}
|
|
|
|
void main() {
|
|
for (final locale in ['en', 'ru']) {
|
|
testWidgets(
|
|
'usage and authoritative available capacity fit narrow $locale layout',
|
|
(tester) async {
|
|
tester.view.physicalSize = const Size(320, 1800);
|
|
tester.view.devicePixelRatio = 1;
|
|
tester.platformDispatcher.textScaleFactorTestValue = 1.6;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
|
final provider = LimitsProvider(
|
|
Service(
|
|
const VisibleLimit(
|
|
period: LimitPeriod.day,
|
|
currency: 'EUR',
|
|
basicMinor: 10000,
|
|
verifiedMinor: 250000,
|
|
currentMinor: 10000,
|
|
remainingMinor: 5500,
|
|
usedMinor: 3000,
|
|
reservedMinor: 1000,
|
|
),
|
|
),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await provider.refresh();
|
|
await tester.pumpWidget(
|
|
ChangeNotifierProvider.value(
|
|
value: provider,
|
|
child: MaterialApp(
|
|
theme: SxchngeTheme.light(),
|
|
locale: Locale(locale),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: const Scaffold(
|
|
body: SingleChildScrollView(child: LimitsPanel()),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.text(
|
|
locale == 'en' ? 'Used this period' : 'Использовано за период',
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
expect(
|
|
find.text(locale == 'en' ? 'Reserved' : 'Зарезервировано'),
|
|
findsNothing,
|
|
);
|
|
expect(
|
|
tester
|
|
.widget<LinearProgressIndicator>(
|
|
find.byKey(const ValueKey('usage-day')),
|
|
)
|
|
.value,
|
|
0.4,
|
|
);
|
|
expect(find.textContaining('55'), findsOneWidget);
|
|
expect(tester.takeException(), null);
|
|
},
|
|
);
|
|
}
|
|
}
|