Skip to content

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-pratik-k committed Aug 3, 2023
1 parent 167bbc1 commit 9a11ffe
Show file tree
Hide file tree
Showing 42 changed files with 301 additions and 346 deletions.
4 changes: 2 additions & 2 deletions lib/data/Repo/leave_repo.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/model/Pagination/pagination.dart';
import 'package:projectunity/data/model/leave/leave.dart';
import 'package:projectunity/data/model/pagination/pagination.dart';
import 'package:projectunity/data/provider/user_state.dart';
import 'package:projectunity/data/services/leave_service.dart';
import 'package:rxdart/rxdart.dart';
Expand All @@ -17,7 +17,7 @@ class LeaveRepo {
Stream<List<Leave>> get pendingLeaves => _leaveService
.allPendingLeaveRequests(spaceId: _userStateNotifier.currentSpaceId!);

Future<LeavesPaginationData> leaves(
Future<PaginatedLeaves> leaves(
{DocumentSnapshot<Leave>? lastDoc, String? uid}) async =>
await _leaveService.leaves(
limit: 5,
Expand Down
2 changes: 1 addition & 1 deletion lib/data/bloc/user_state/user_state_controller_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:projectunity/data/bloc/user_state/space_change_notifier.dart';
import 'package:projectunity/data/bloc/user_state/user_state_controller_event.dart';
import 'package:projectunity/data/bloc/user_state/user_controller_state.dart';
import 'package:projectunity/data/model/space/space.dart';
import '../../Repo/employee_repo.dart';
import '../../repo/employee_repo.dart';
import '../../model/employee/employee.dart';
import '../../provider/user_state.dart';
import '../../services/space_service.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/data/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions lib/data/model/pagination/pagination.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:cloud_firestore/cloud_firestore.dart' show DocumentSnapshot;
import 'package:equatable/equatable.dart';
import '../leave/leave.dart';

class LeavesPaginationData{
class PaginatedLeaves extends Equatable {
final DocumentSnapshot<Leave> lastDoc;
final List<Leave> leaves;

LeavesPaginationData({required this.leaves, required this.lastDoc});
}
const PaginatedLeaves({required this.leaves, required this.lastDoc});

@override
List<Object?> get props => [leaves, lastDoc];
}
6 changes: 3 additions & 3 deletions lib/data/services/leave_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/core/extensions/date_time.dart';
import 'package:projectunity/data/core/extensions/leave_extension.dart';
import 'package:projectunity/data/model/Pagination/pagination.dart';
import 'package:projectunity/data/model/pagination/pagination.dart';
import '../core/utils/const/firestore.dart';
import '../model/leave/leave.dart';
import '../provider/user_state.dart';
Expand Down Expand Up @@ -32,7 +32,7 @@ class LeaveService {
.snapshots()
.asyncMap((event) => event.docs.map((e) => e.data()).toList());

Future<LeavesPaginationData> leaves(
Future<PaginatedLeaves> leaves(
{DocumentSnapshot<Leave>? lastDoc,
String? uid,
required String spaceId,
Expand All @@ -50,7 +50,7 @@ class LeaveService {

final leavesDoc = await query.limit(limit).get();

return LeavesPaginationData(
return PaginatedLeaves(
leaves: leavesDoc.docs.map((e) => e.data()).toList(),
lastDoc: leavesDoc.docs.isNotEmpty ? leavesDoc.docs.last : lastDoc!);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/admin/home/home_screen/bloc/admin_home_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/Repo/employee_repo.dart';
import 'package:projectunity/data/Repo/leave_repo.dart';
import 'package:projectunity/data/repo/employee_repo.dart';
import 'package:projectunity/data/repo/leave_repo.dart';
import 'package:projectunity/data/core/extensions/date_time.dart';
import 'package:projectunity/data/core/extensions/list.dart';
import 'package:projectunity/data/core/utils/bloc_status.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/admin/leaves/leave_screen/bloc /admin_leaves_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:injectable/injectable.dart';
import 'package:projectunity/data/core/extensions/list.dart';
import 'package:projectunity/data/core/extensions/stream_extension.dart';
import 'package:projectunity/data/core/utils/bloc_status.dart';
import '../../../../../data/Repo/employee_repo.dart';
import '../../../../../data/Repo/leave_repo.dart';
import '../../../../../data/repo/employee_repo.dart';
import '../../../../../data/repo/leave_repo.dart';
import '../../../../../data/core/exception/error_const.dart';
import '../../../../../data/model/employee/employee.dart';
import '../../../../../data/model/leave/leave.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/admin/members/detail/bloc/employee_detail_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:injectable/injectable.dart';
import 'package:projectunity/data/provider/user_state.dart';
import 'package:projectunity/data/services/account_service.dart';
import 'package:projectunity/data/services/space_service.dart';
import '../../../../../data/Repo/employee_repo.dart';
import '../../../../../data/repo/employee_repo.dart';
import '../../../../../data/core/exception/error_const.dart';
import '../../../../../data/model/employee/employee.dart';
import '../../../../../data/services/employee_service.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/core/utils/bloc_status.dart';
import '../../../../../data/Repo/leave_repo.dart';
import '../../../../../data/repo/leave_repo.dart';
import '../../../../../data/core/exception/error_const.dart';
import '../../../../../data/model/leave/leave.dart';
import 'admin_employee_details_leave_state.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/admin/members/list/bloc/member_list_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'dart:async';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/Repo/employee_repo.dart';
import 'package:projectunity/data/repo/employee_repo.dart';
import 'package:projectunity/data/provider/user_state.dart';
import 'package:projectunity/data/services/invitation_services.dart';
import '../../../../../data/core/exception/error_const.dart';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/data/Repo/employee_repo.dart';
import 'package:projectunity/data/repo/employee_repo.dart';
import 'package:projectunity/data/core/exception/error_const.dart';
import 'package:projectunity/data/model/employee/employee.dart';
import 'package:projectunity/ui/shared/profile/view_profile/bloc/view_profile_event.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/shared/who_is_out_card/bloc/who_is_out_card_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:injectable/injectable.dart';
import 'package:projectunity/data/core/extensions/date_time.dart';
import 'package:projectunity/data/core/extensions/leave_extension.dart';
import 'package:projectunity/data/core/extensions/stream_extension.dart';
import '../../../../data/Repo/employee_repo.dart';
import '../../../../data/Repo/leave_repo.dart';
import '../../../../data/repo/employee_repo.dart';
import '../../../../data/repo/leave_repo.dart';
import '../../../../data/core/exception/error_const.dart';
import '../../../../data/core/utils/bloc_status.dart';
import '../../../../data/model/leave/leave.dart';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/user/home/home_screen/bloc/user_home_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/ui/user/home/home_screen/bloc/user_home_event.dart';
import 'package:projectunity/ui/user/home/home_screen/bloc/user_home_state.dart';
import '../../../../../data/Repo/leave_repo.dart';
import '../../../../../data/repo/leave_repo.dart';
import '../../../../../data/core/exception/error_const.dart';
import '../../../../../data/model/leave/leave.dart';
import '../../../../../data/provider/user_state.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/ui/user/leaves/leaves_screen/bloc/leaves/user_leave_event.dart';
import 'package:projectunity/ui/user/leaves/leaves_screen/bloc/leaves/user_leave_state.dart';
import '../../../../../../data/Repo/leave_repo.dart';
import '../../../../../../data/repo/leave_repo.dart';
import '../../../../../../data/core/exception/error_const.dart';
import '../../../../../../data/core/utils/bloc_status.dart';
import '../../../../../../data/model/leave/leave.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
import 'package:projectunity/ui/user/members/members_screen/bloc/user_members_event.dart';
import 'package:projectunity/ui/user/members/members_screen/bloc/user_members_state.dart';
import '../../../../../data/Repo/employee_repo.dart';
import '../../../../../data/repo/employee_repo.dart';
import '../../../../../data/core/exception/error_const.dart';
import '../../../../../data/model/employee/employee.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import 'package:projectunity/data/Repo/employee_repo.dart';
import 'package:projectunity/data/Repo/leave_repo.dart';
import 'package:projectunity/data/repo/employee_repo.dart';
import 'package:projectunity/data/repo/leave_repo.dart';
import 'package:projectunity/data/core/exception/error_const.dart';
import 'package:projectunity/data/core/extensions/date_time.dart';
import 'package:projectunity/data/core/utils/bloc_status.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:cloud_firestore/cloud_firestore.dart' as _i8;
import 'package:mockito/mockito.dart' as _i1;
import 'package:projectunity/data/model/employee/employee.dart' as _i5;
import 'package:projectunity/data/model/leave/leave.dart' as _i7;
import 'package:projectunity/data/model/Pagination/pagination.dart' as _i2;
import 'package:projectunity/data/Repo/employee_repo.dart' as _i3;
import 'package:projectunity/data/Repo/leave_repo.dart' as _i6;
import 'package:projectunity/data/model/pagination/pagination.dart' as _i2;
import 'package:projectunity/data/repo/employee_repo.dart' as _i3;
import 'package:projectunity/data/repo/leave_repo.dart' as _i6;

// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
Expand All @@ -24,9 +24,9 @@ import 'package:projectunity/data/Repo/leave_repo.dart' as _i6;
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class

class _FakeLeavesPaginationData_0 extends _i1.SmartFake
implements _i2.LeavesPaginationData {
_FakeLeavesPaginationData_0(
class _FakePaginatedLeaves_0 extends _i1.SmartFake
implements _i2.PaginatedLeaves {
_FakePaginatedLeaves_0(
Object parent,
Invocation parentInvocation,
) : super(
Expand Down Expand Up @@ -100,7 +100,7 @@ class MockLeaveRepo extends _i1.Mock implements _i6.LeaveRepo {
returnValue: _i4.Stream<List<_i7.Leave>>.empty(),
) as _i4.Stream<List<_i7.Leave>>);
@override
_i4.Future<_i2.LeavesPaginationData> leaves({
_i4.Future<_i2.PaginatedLeaves> leaves({
_i8.DocumentSnapshot<_i7.Leave>? lastDoc,
String? uid,
}) =>
Expand All @@ -113,8 +113,8 @@ class MockLeaveRepo extends _i1.Mock implements _i6.LeaveRepo {
#uid: uid,
},
),
returnValue: _i4.Future<_i2.LeavesPaginationData>.value(
_FakeLeavesPaginationData_0(
returnValue:
_i4.Future<_i2.PaginatedLeaves>.value(_FakePaginatedLeaves_0(
this,
Invocation.method(
#leaves,
Expand All @@ -125,7 +125,7 @@ class MockLeaveRepo extends _i1.Mock implements _i6.LeaveRepo {
},
),
)),
) as _i4.Future<_i2.LeavesPaginationData>);
) as _i4.Future<_i2.PaginatedLeaves>);
@override
_i4.Stream<List<_i7.Leave>> userLeaveRequest(String? uid) =>
(super.noSuchMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:mockito/mockito.dart' as _i1;
import 'package:projectunity/data/model/account/account.dart' as _i9;
import 'package:projectunity/data/model/employee/employee.dart' as _i4;
import 'package:projectunity/data/model/leave/leave.dart' as _i7;
import 'package:projectunity/data/model/Pagination/pagination.dart' as _i3;
import 'package:projectunity/data/model/pagination/pagination.dart' as _i3;
import 'package:projectunity/data/model/space/space.dart' as _i10;
import 'package:projectunity/data/provider/user_state.dart' as _i8;
import 'package:projectunity/data/services/leave_service.dart' as _i5;
Expand Down Expand Up @@ -41,9 +41,9 @@ class _FakeFirebaseFirestore_0 extends _i1.SmartFake
);
}

class _FakeLeavesPaginationData_1 extends _i1.SmartFake
implements _i3.LeavesPaginationData {
_FakeLeavesPaginationData_1(
class _FakePaginatedLeaves_1 extends _i1.SmartFake
implements _i3.PaginatedLeaves {
_FakePaginatedLeaves_1(
Object parent,
Invocation parentInvocation,
) : super(
Expand Down Expand Up @@ -103,7 +103,7 @@ class MockLeaveService extends _i1.Mock implements _i5.LeaveService {
returnValue: _i6.Stream<List<_i7.Leave>>.empty(),
) as _i6.Stream<List<_i7.Leave>>);
@override
_i6.Future<_i3.LeavesPaginationData> leaves({
_i6.Future<_i3.PaginatedLeaves> leaves({
_i2.DocumentSnapshot<_i7.Leave>? lastDoc,
String? uid,
required String? spaceId,
Expand All @@ -120,8 +120,8 @@ class MockLeaveService extends _i1.Mock implements _i5.LeaveService {
#limit: limit,
},
),
returnValue: _i6.Future<_i3.LeavesPaginationData>.value(
_FakeLeavesPaginationData_1(
returnValue:
_i6.Future<_i3.PaginatedLeaves>.value(_FakePaginatedLeaves_1(
this,
Invocation.method(
#leaves,
Expand All @@ -134,7 +134,7 @@ class MockLeaveService extends _i1.Mock implements _i5.LeaveService {
},
),
)),
) as _i6.Future<_i3.LeavesPaginationData>);
) as _i6.Future<_i3.PaginatedLeaves>);
@override
_i6.Stream<List<_i7.Leave>> monthlyLeaveByStartDate({
required int? year,
Expand Down
Loading

0 comments on commit 9a11ffe

Please sign in to comment.