Skip to content

Commit

Permalink
Delete final batchSetPillSheet.+
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai committed Nov 28, 2022
1 parent 68bda7c commit 4393e60
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 126 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ class DisplayNumberSettingSheet extends HookConsumerWidget {
final height = 1 - ((estimatedKeyboardHeight - offset) / MediaQuery.of(context).size.height);

final batchFactory = ref.watch(batchFactoryProvider);
final batchSetPillSheetGroup = ref.watch(batchSetPillSheetGroupProvider);
final batchSetPillSheetModifiedHistory = ref.watch(batchSetPillSheetModifiedHistoryProvider);

return DraggableScrollableSheet(
initialChildSize: height,
Expand Down
2 changes: 0 additions & 2 deletions lib/provider/pill_sheet_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ final beforePillSheetGroupProvider = FutureProvider<PillSheetGroup?>((ref) async
return snapshot.docs[0].data();
});

final batchSetPillSheetGroupProvider = Provider((ref) => BatchSetPillSheetGroup(ref.watch(databaseProvider)));

class BatchSetPillSheetGroup {
final DatabaseConnection databaseConnection;
BatchSetPillSheetGroup(this.databaseConnection);
Expand Down
2 changes: 0 additions & 2 deletions lib/provider/pill_sheet_modified_history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ final pillSheetModifiedHistoriesWithLimitProvider = StreamProvider.family((ref,
.map((docs) => docs.map((doc) => doc.data()).toList());
});

final batchSetPillSheetModifiedHistoryProvider = Provider((ref) => BatchSetPillSheetModifiedHistory(ref.watch(databaseProvider)));

class BatchSetPillSheetModifiedHistory {
final DatabaseConnection databaseConnection;
BatchSetPillSheetModifiedHistory(this.databaseConnection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void main() {
final batchFactory = MockBatchFactory();
final endInitialSetting = MockEndInitialSetting();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand All @@ -66,9 +66,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand Down Expand Up @@ -103,9 +103,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand Down Expand Up @@ -134,9 +134,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand Down Expand Up @@ -166,9 +166,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand Down Expand Up @@ -202,9 +202,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand All @@ -230,9 +230,9 @@ void main() {
final endInitialSetting = MockEndInitialSetting();
final batchFactory = MockBatchFactory();
final batchSetSetting = MockBatchSetSetting();
final batchSetPillSheets = MockBatchSetPillSheets();
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();




final container = ProviderContainer(
overrides: [
Expand Down Expand Up @@ -265,16 +265,16 @@ void main() {
when(batchFactory.batch()).thenReturn(batch);

final pillSheet = PillSheet(id: firestoreIDGenerator(), typeInfo: PillSheetType.pillsheet_21.typeInfo, beginingDate: _today);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [pillSheet])).thenReturn([pillSheet.copyWith(id: "sheet_id")]);

final pillSheetGroup = PillSheetGroup(pillSheetIDs: ["sheet_id"], pillSheets: [pillSheet.copyWith(id: "sheet_id")], createdAt: now());
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, pillSheetGroup)).thenReturn(pillSheetGroup.copyWith(id: "group_id"));

final history =
PillSheetModifiedHistoryServiceActionFactory.createCreatedPillSheetAction(pillSheetGroupID: "group_id", pillSheetIDs: ["sheet_id"]);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

const setting = Setting(
Expand Down Expand Up @@ -336,7 +336,7 @@ void main() {
lastTakenDate: _today.subtract(const Duration(days: 1)),
groupIndex: 1,
);
final batchSetPillSheets = MockBatchSetPillSheets();


when(batchSetPillSheets(batch, [pillSheet, pillSheet2])).thenReturn([pillSheet.copyWith(id: "sheet_id"), pillSheet2.copyWith(id: "sheet_id2")]);

Expand All @@ -348,12 +348,12 @@ void main() {
],
createdAt: now(),
);
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, pillSheetGroup)).thenReturn(pillSheetGroup.copyWith(id: "group_id"));

final history = PillSheetModifiedHistoryServiceActionFactory.createCreatedPillSheetAction(
pillSheetGroupID: "group_id", pillSheetIDs: ["sheet_id", "sheet_id2"]);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

const setting = Setting(
Expand Down Expand Up @@ -415,16 +415,16 @@ void main() {
when(batchFactory.batch()).thenReturn(batch);

final pillSheet = PillSheet(id: firestoreIDGenerator(), typeInfo: PillSheetType.pillsheet_24_rest_4.typeInfo, beginingDate: _today);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [pillSheet])).thenReturn([pillSheet.copyWith(id: "sheet_id")]);

final pillSheetGroup = PillSheetGroup(pillSheetIDs: ["sheet_id"], pillSheets: [pillSheet.copyWith(id: "sheet_id")], createdAt: now());
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, pillSheetGroup)).thenReturn(pillSheetGroup.copyWith(id: "group_id"));

final history =
PillSheetModifiedHistoryServiceActionFactory.createCreatedPillSheetAction(pillSheetGroupID: "group_id", pillSheetIDs: ["sheet_id"]);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

final batchSetSetting = MockBatchSetSetting();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ void main() {
final pillSheet =
PillSheet(id: firestoreIDGenerator(), id: "pill_sheet_id_1", typeInfo: PillSheetType.pillsheet_28_0.typeInfo, beginingDate: now());
final updatedPillSheet = pillSheet.copyWith(restDurations: [notYetEndRestDuration]);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [updatedPillSheet])).thenReturn([updatedPillSheet]);

final pillSheetGroup = PillSheetGroup(id: "group_id", pillSheetIDs: ["pill_sheet_id_1"].toList(), pillSheets: [pillSheet], createdAt: now());
final updatedPillSheetGroup =
PillSheetGroup(id: "group_id", pillSheetIDs: ["pill_sheet_id_1"].toList(), pillSheets: [updatedPillSheet], createdAt: now());
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, updatedPillSheetGroup)).thenReturn(updatedPillSheetGroup.copyWith(id: "group_id"));

final history = PillSheetModifiedHistoryServiceActionFactory.createBeganRestDurationAction(
pillSheetGroupID: "group_id", before: pillSheet, after: updatedPillSheet, restDuration: notYetEndRestDuration);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

final beginRestDuration = BeginRestDuration(
Expand Down Expand Up @@ -89,18 +89,18 @@ void main() {
beginingDate: now(),
restDurations: [notYetEndRestDuration]);
final updatedPillSheet = pillSheet.copyWith(restDurations: [endedRestDuration]);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [updatedPillSheet])).thenReturn([updatedPillSheet]);

final pillSheetGroup = PillSheetGroup(id: "group_id", pillSheetIDs: ["pill_sheet_id_1"].toList(), pillSheets: [pillSheet], createdAt: now());
final updatedPillSheetGroup =
PillSheetGroup(id: "group_id", pillSheetIDs: ["pill_sheet_id_1"].toList(), pillSheets: [updatedPillSheet], createdAt: now());
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, updatedPillSheetGroup)).thenReturn(updatedPillSheetGroup.copyWith(id: "group_id"));

final history = PillSheetModifiedHistoryServiceActionFactory.createEndedRestDurationAction(
pillSheetGroupID: "group_id", before: pillSheet, after: updatedPillSheet, restDuration: endedRestDuration);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

final endRestDuration = EndRestDuration(
Expand Down Expand Up @@ -166,7 +166,7 @@ void main() {
updatedPillSheet2,
updatedPillSheet3,
];
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, updatedPillSheets)).thenReturn(updatedPillSheets);
expect(
isSameDay(pillSheets[0].beginingDate, updatedPillSheet1.beginingDate),
Expand All @@ -184,12 +184,12 @@ void main() {
final pillSheetGroup =
PillSheetGroup(id: "group_id", pillSheetIDs: pillSheets.map((e) => e.id!).toList(), pillSheets: pillSheets, createdAt: now());
final updatedPillSheetGroup = pillSheetGroup.copyWith(pillSheets: updatedPillSheets);
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, updatedPillSheetGroup)).thenReturn(updatedPillSheetGroup.copyWith(id: "group_id"));

final history = PillSheetModifiedHistoryServiceActionFactory.createEndedRestDurationAction(
pillSheetGroupID: "group_id", before: pillSheets[0], after: updatedPillSheets[0], restDuration: endedRestDuration);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

final endRestDuration = EndRestDuration(
Expand Down
12 changes: 6 additions & 6 deletions test/features/record/provider/add_pill_sheet_group_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void main() {
groupIndex: 0,
lastTakenDate: null,
);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [pillSheet])).thenReturn([
pillSheet.copyWith(id: "sheet_id"),
]);
Expand All @@ -47,12 +47,12 @@ void main() {
],
createdAt: now(),
);
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, pillSheetGroup)).thenReturn(pillSheetGroup.copyWith(id: "group_id"));

final history =
PillSheetModifiedHistoryServiceActionFactory.createCreatedPillSheetAction(pillSheetGroupID: "group_id", pillSheetIDs: ["sheet_id"]);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

const setting = Setting(
Expand Down Expand Up @@ -116,7 +116,7 @@ void main() {
lastTakenDate: null,
groupIndex: 1,
);
final batchSetPillSheets = MockBatchSetPillSheets();

when(batchSetPillSheets(batch, [pillSheet, pillSheet2])).thenReturn([pillSheet.copyWith(id: "sheet_id"), pillSheet2.copyWith(id: "sheet_id2")]);

final pillSheetGroup = PillSheetGroup(
Expand All @@ -127,12 +127,12 @@ void main() {
],
createdAt: now(),
);
final batchSetPillSheetGroup = MockBatchSetPillSheetGroup();

when(batchSetPillSheetGroup(batch, pillSheetGroup)).thenReturn(pillSheetGroup.copyWith(id: "group_id"));

final history = PillSheetModifiedHistoryServiceActionFactory.createCreatedPillSheetAction(
pillSheetGroupID: "group_id", pillSheetIDs: ["sheet_id", "sheet_id2"]);
final batchSetPillSheetModifiedHistory = MockBatchSetPillSheetModifiedHistory();

when(batchSetPillSheetModifiedHistory(batch, history)).thenReturn(null);

const setting = Setting(
Expand Down
Loading

0 comments on commit 4393e60

Please sign in to comment.