fix : update local.properties path and improve null safety in chicken_local_imp.dart and chicken_repository_imp.dart; refactor profile view for better readability
This commit is contained in:
221
packages/chicken/test/presentation/utils/string_utils_test.dart
Normal file
221
packages/chicken/test/presentation/utils/string_utils_test.dart
Normal file
@@ -0,0 +1,221 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_chicken/presentation/utils/string_utils.dart';
|
||||
|
||||
void main() {
|
||||
group('XStringUtils', () {
|
||||
group('faAllocationType', () {
|
||||
test('should convert simple string using utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'killhouse';
|
||||
const expected = 'کشتارگاه به';
|
||||
|
||||
// Act
|
||||
final result = input.faAllocationType;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should convert string with underscore using utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'steward_exclusive';
|
||||
const expected = 'مباشر به اختصاصی';
|
||||
|
||||
// Act
|
||||
final result = input.faAllocationType;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should return original string when not found in utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'unknown_string';
|
||||
const expected = 'unknown به string';
|
||||
|
||||
// Act
|
||||
final result = input.faAllocationType;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should handle single word without underscore', () {
|
||||
// Arrange
|
||||
const input = 'free';
|
||||
const expected = 'آزاد به';
|
||||
|
||||
// Act
|
||||
final result = input.faAllocationType;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should handle multiple underscores correctly', () {
|
||||
// Arrange
|
||||
const input = 'steward_exclusive_guild';
|
||||
const expected = 'مباشر به اختصاصی صنف';
|
||||
|
||||
// Act
|
||||
final result = input.faAllocationType;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
group('faItem', () {
|
||||
test('should convert string using utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'pending';
|
||||
const expected = 'در انتظار';
|
||||
|
||||
// Act
|
||||
final result = input.faItem;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should return original string when not found in utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'unknown_item';
|
||||
const expected = 'unknown_item';
|
||||
|
||||
// Act
|
||||
final result = input.faItem;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should handle empty string', () {
|
||||
// Arrange
|
||||
const input = '';
|
||||
const expected = '';
|
||||
|
||||
// Act
|
||||
final result = input.faItem;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
});
|
||||
|
||||
group('buyerIsGuild', () {
|
||||
test('should return true when last part is guild', () {
|
||||
// Arrange
|
||||
const input = 'steward_exclusive_guild';
|
||||
|
||||
// Act
|
||||
final result = input.buyerIsGuild;
|
||||
|
||||
// Assert
|
||||
expect(result, isTrue);
|
||||
});
|
||||
|
||||
test('should return false when last part is not guild', () {
|
||||
// Arrange
|
||||
const input = 'steward_exclusive_governmental';
|
||||
|
||||
// Act
|
||||
final result = input.buyerIsGuild;
|
||||
|
||||
// Assert
|
||||
expect(result, isFalse);
|
||||
});
|
||||
|
||||
test('should return false for single word', () {
|
||||
// Arrange
|
||||
const input = 'guild';
|
||||
|
||||
// Act
|
||||
final result = input.buyerIsGuild;
|
||||
|
||||
// Assert
|
||||
expect(result, isFalse);
|
||||
});
|
||||
|
||||
test('should return false for empty string', () {
|
||||
// Arrange
|
||||
const input = '';
|
||||
|
||||
// Act
|
||||
final result = input.buyerIsGuild;
|
||||
|
||||
// Assert
|
||||
expect(result, isFalse);
|
||||
});
|
||||
});
|
||||
|
||||
group('faTitle', () {
|
||||
test('should convert string using utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'accepted';
|
||||
const expected = 'تایید شده';
|
||||
|
||||
// Act
|
||||
final result = input.faTitle;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should return original string when not found in utilsMap', () {
|
||||
// Arrange
|
||||
const input = 'unknown_title';
|
||||
const expected = 'unknown_title';
|
||||
|
||||
// Act
|
||||
final result = input.faTitle;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
|
||||
test('should handle empty string', () {
|
||||
// Arrange
|
||||
const input = '';
|
||||
const expected = '';
|
||||
|
||||
// Act
|
||||
final result = input.faTitle;
|
||||
|
||||
// Assert
|
||||
expect(result, equals(expected));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
group('utilsMap', () {
|
||||
test('should contain expected key-value pairs', () {
|
||||
// Assert
|
||||
expect(utilsMap['killhouse'], equals('کشتارگاه'));
|
||||
expect(utilsMap['_'], equals('به'));
|
||||
expect(utilsMap['steward'], equals('مباشر'));
|
||||
expect(utilsMap['exclusive'], equals('اختصاصی'));
|
||||
expect(utilsMap['free'], equals('آزاد'));
|
||||
expect(utilsMap['pending'], equals('در انتظار'));
|
||||
expect(utilsMap['accepted'], equals('تایید شده'));
|
||||
expect(utilsMap['guild'], equals('صنف'));
|
||||
expect(utilsMap['governmental'], equals('دولتی'));
|
||||
});
|
||||
|
||||
test('should not be empty', () {
|
||||
// Assert
|
||||
expect(utilsMap.isNotEmpty, isTrue);
|
||||
});
|
||||
|
||||
test('should have consistent key-value pairs', () {
|
||||
// Assert
|
||||
expect(utilsMap.length, equals(9));
|
||||
expect(utilsMap.keys, contains('killhouse'));
|
||||
expect(utilsMap.keys, contains('steward'));
|
||||
expect(utilsMap.keys, contains('guild'));
|
||||
expect(utilsMap.values, contains('کشتارگاه'));
|
||||
expect(utilsMap.values, contains('مباشر'));
|
||||
expect(utilsMap.values, contains('صنف'));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user