import 'package:flutter_test/flutter_test.dart'; import 'package:eaimar/core/translations/language/en_us.dart'; import 'package:eaimar/core/translations/language/is_is.dart'; Set _extractPlaceholders(String value) { final placeholders = {}; placeholders.addAll( RegExp(r'\{[a-zA-Z_][a-zA-Z0-9_]*\}') .allMatches(value) .map((m) => m.group(0)!) .toSet(), ); placeholders.addAll( RegExp(r'@[a-zA-Z_][a-zA-Z0-9_]*') .allMatches(value) .map((m) => m.group(0)!) .toSet(), ); placeholders.addAll( RegExp(r'\$\{[a-zA-Z_][a-zA-Z0-9_]*\}') .allMatches(value) .map((m) => m.group(0)!) .toSet(), ); placeholders.addAll( RegExp(r'%(?:\d+\$)?[sdif]') .allMatches(value) .map((m) => m.group(0)!) .toSet(), ); return placeholders; } void main() { test('isIS can be imported and accessed', () { expect(isIS, isNotEmpty); expect(isIS['continue'], isNotNull); }); test('isIS has the same translation keys as enUS', () { expect(isIS.keys.toSet(), equals(enUS.keys.toSet())); }); test('isIS has no empty values', () { final emptyKeys = isIS.entries .where((entry) => entry.value.trim().isEmpty) .map((entry) => entry.key) .toList(growable: false); expect(emptyKeys, isEmpty); }); test('isIS placeholders match enUS placeholders', () { final mismatches = []; for (final key in enUS.keys) { final enValue = enUS[key] ?? ''; final isValue = isIS[key] ?? ''; final enPlaceholders = _extractPlaceholders(enValue); final isPlaceholders = _extractPlaceholders(isValue); if (enPlaceholders.length != isPlaceholders.length || !enPlaceholders.containsAll(isPlaceholders) || !isPlaceholders.containsAll(enPlaceholders)) { mismatches.add( '$key | en=$enPlaceholders | is=$isPlaceholders | enValue=$enValue | isValue=$isValue', ); } } expect(mismatches, isEmpty); }); }