import 'package:flutter_test/flutter_test.dart'; import 'package:new_budget/src/features/notification_parsing/data/parser/dedup.dart'; import 'package:new_budget/src/features/notification_parsing/data/parser/merchant_normalizer.dart'; void main() { group('normalizeMerchant', () { test('strips tail after star', () { expect(normalizeMerchant('WBSPB*MOSCOW'), 'WBSPB'); }); test('strips trailing point-of-sale digits', () { expect(normalizeMerchant('PYATEROCHKA 2351'), 'PYATEROCHKA'); }); test('collapses internal whitespace and trims', () { expect(normalizeMerchant(' MAGNIT U '), 'MAGNIT U'); }); test('falls back to trimmed raw if normalization empties it', () { expect(normalizeMerchant(' 123 '), '123'); }); }); group('computeDedupHash', () { test('is deterministic', () { final a = computeDedupHash('pkg', 'Покупка 1240 ₽'); final b = computeDedupHash('pkg', 'Покупка 1240 ₽'); expect(a, b); }); test('differs for different body', () { final a = computeDedupHash('pkg', 'Покупка 1240 ₽'); final b = computeDedupHash('pkg', 'Покупка 1250 ₽'); expect(a, isNot(b)); }); test('differs for different package', () { final a = computeDedupHash('pkg1', 'same'); final b = computeDedupHash('pkg2', 'same'); expect(a, isNot(b)); }); test('fixed-width 16-hex output', () { final h = computeDedupHash('pkg', 'x'); expect(h.length, 16); expect(RegExp(r'^[0-9a-f]{16}$').hasMatch(h), isTrue); }); }); }