48 lines
1.7 KiB
Dart
48 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:sxchnge_kyc/sxchnge_kyc.dart';
|
|
import 'package:sxchnge_kyc/src/transport/contracts.dart';
|
|
|
|
void main() {
|
|
test('mapping preserves backend usage and independent remaining value', () {
|
|
final data = LimitsMapper.fromDTO(
|
|
const LimitsDTO(
|
|
tier: 'basic',
|
|
simulated: false,
|
|
rows: [LimitDTO('day', 'EUR', 10000, 250000, 10000, 5500, 3000, 1000)],
|
|
),
|
|
);
|
|
final row = data.rows.single;
|
|
expect(row.usedMinor, 3000);
|
|
expect(row.reservedMinor, 1000);
|
|
expect(row.remainingMinor, 5500);
|
|
expect(row.occupiedFraction, 0.4);
|
|
});
|
|
test('capacity visualization handles unused, exhausted and zero caps', () {
|
|
VisibleLimit row(int cap, int used, int reserved) => VisibleLimit(
|
|
period: LimitPeriod.day,
|
|
currency: 'EUR',
|
|
basicMinor: cap,
|
|
verifiedMinor: cap,
|
|
currentMinor: cap,
|
|
remainingMinor: 0,
|
|
usedMinor: used,
|
|
reservedMinor: reserved,
|
|
);
|
|
expect(row(10000, 0, 0).occupiedFraction, 0);
|
|
expect(row(10000, 8000, 2000).occupiedFraction, 1);
|
|
expect(row(10000, 12000, 2000).occupiedFraction, 1);
|
|
expect(row(0, 0, 0).occupiedFraction, 0);
|
|
});
|
|
test('stub provides nonzero daily and monthly usage', () async {
|
|
final identity = DummyIdentityService(delay: Duration.zero);
|
|
final service = DummyLimitsService(identity);
|
|
final data = await service.fetch();
|
|
expect(data.rows.first.usedMinor, 3000);
|
|
expect(data.rows.first.reservedMinor, 1000);
|
|
expect(data.rows.first.remainingMinor, 6000);
|
|
expect(data.rows.last.usedMinor, 18000);
|
|
expect(data.rows.last.remainingMinor, 31000);
|
|
});
|
|
}
|