feat : new ui and fix bug's
This commit is contained in:
15
packages/chicken/test/data/common/constant_test.dart
Normal file
15
packages/chicken/test/data/common/constant_test.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// File: packages/chicken/test/data/common/constant_test.dart
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_chicken/data/common/constant.dart';
|
||||
|
||||
void main() {
|
||||
group('ApiEnvironment', () {
|
||||
test('dam environment returns correct baseUrl', () {
|
||||
expect(ApiEnvironment.dam.baseUrl, 'https://api.dam.rasadyar.net/');
|
||||
});
|
||||
|
||||
test('dam environment url property is correct', () {
|
||||
expect(ApiEnvironment.dam.url, 'https://api.dam.rasadyar.net/');
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:mocktail/mocktail.dart';
|
||||
import 'package:rasadyar_chicken/data/common/dio_error_handler.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
class MockGet extends Mock implements GetInterface {}
|
||||
|
||||
void main() {
|
||||
late DioErrorHandler errorHandler;
|
||||
late MockGet mockGet;
|
||||
|
||||
setUp(() {
|
||||
errorHandler = DioErrorHandler();
|
||||
mockGet = MockGet();
|
||||
Get.testMode = true;
|
||||
Get.put<GetInterface>(mockGet);
|
||||
});
|
||||
|
||||
/*test('handle 410 Error', () {
|
||||
final error = DioException(
|
||||
response: Response(statusCode: 410, requestOptions: RequestOptions(path: "/")),
|
||||
requestOptions: RequestOptions(path: "/"),
|
||||
);
|
||||
|
||||
errorHandler.handle(error);
|
||||
|
||||
verify(
|
||||
() => mockGet.showSnackbar(
|
||||
any(
|
||||
that: isA<GetSnackBar>().having(
|
||||
(s) => (s.messageText as Text).data,
|
||||
'messageText',
|
||||
'نام کاربری یا رمز عبور اشتباه است',
|
||||
),
|
||||
),
|
||||
),
|
||||
).called(1);
|
||||
});*/
|
||||
}
|
||||
26
packages/chicken/test/data/common/fa_user_role_test.dart
Normal file
26
packages/chicken/test/data/common/fa_user_role_test.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_chicken/data/common/fa_user_role.dart';
|
||||
import 'package:rasadyar_chicken/presentation/routes/routes.dart';
|
||||
|
||||
void main() {
|
||||
group('getFaUserRole', () {
|
||||
test('returns correct Farsi role for known roles and unknown/null', () {
|
||||
expect(getFaUserRole('Admin'), 'ادمین استان');
|
||||
expect(getFaUserRole('Poultry'), 'مرغدار');
|
||||
expect(getFaUserRole('ProvinceFinancial'), 'مالی اتحادیه');
|
||||
expect(getFaUserRole('SuperAdmin'), 'ادمین کل');
|
||||
expect(getFaUserRole('UnknownRole'), 'نامشخص');
|
||||
expect(getFaUserRole(null), 'نامشخص');
|
||||
});
|
||||
});
|
||||
|
||||
group('getFaUserRoleWithOnTap', () {
|
||||
test('returns correct map for known roles and unknown/null', () {
|
||||
expect(getFaUserRoleWithOnTap('Admin'), {'ادمین استان': null});
|
||||
expect(getFaUserRoleWithOnTap('Steward'), {'مباشر': ChickenRoutes.initSteward});
|
||||
expect(getFaUserRoleWithOnTap('PoultryScience'), {'کارشناس طیور': ChickenRoutes.initPoultryScience});
|
||||
expect(getFaUserRoleWithOnTap('UnknownRole'), {'نامشخص': null});
|
||||
expect(getFaUserRoleWithOnTap(null), {'نامشخص': null});
|
||||
});
|
||||
});
|
||||
}
|
||||
19
packages/chicken/test/data/di/chicken_di_test.dart
Normal file
19
packages/chicken/test/data/di/chicken_di_test.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:rasadyar_chicken/data/common/dio_error_handler.dart';
|
||||
import 'package:rasadyar_chicken/data/di/chicken_di.dart';
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() async {
|
||||
await setupAllCoreProvider();
|
||||
Get.put(TokenStorageService());
|
||||
await setupChickenDI();
|
||||
});
|
||||
|
||||
group('Check class type registered', () {
|
||||
test('DioErrorHandler is registered', () {
|
||||
expect(diChicken, isA<GetIt>());
|
||||
expect(diChicken.isRegistered<DioErrorHandler>(), true);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user