Skip to content

Commit

Permalink
Fix/Change name of state to "SavedSuccessfully".
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-Sander committed Oct 25, 2023
1 parent 55627f3 commit 56ae7c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions app/lib/blocs/homework/homework_dialog_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ class Ready extends HomeworkDialogState {
}
}

class SavedSucessfully extends HomeworkDialogState {
class SavedSuccessfully extends HomeworkDialogState {
@override
List<Object?> get props => [super.isEditing];

const SavedSucessfully({required super.isEditing});
const SavedSuccessfully({required super.isEditing});
}

class FileView extends Equatable {
Expand Down Expand Up @@ -518,7 +518,7 @@ class HomeworkDialogBloc extends Bloc<HomeworkDialogEvent, HomeworkDialogState>
}
}

emit(SavedSucessfully(isEditing: isEditing));
emit(SavedSuccessfully(isEditing: isEditing));
},
);
on<TitleChanged>(
Expand Down
6 changes: 3 additions & 3 deletions app/lib/pages/homework/homework_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ class HomeworkDialogMainState extends State<HomeworkDialogMain> {
}
},
child: BlocConsumer<HomeworkDialogBloc, HomeworkDialogState>(
buildWhen: (previous, current) => current is! SavedSucessfully,
buildWhen: (previous, current) => current is! SavedSuccessfully,
listener: (context, state) {
if (state is SavedSucessfully) {
if (state is SavedSuccessfully) {
ScaffoldMessenger.of(context).hideCurrentSnackBar();
Navigator.pop(context);
}
Expand All @@ -206,7 +206,7 @@ class HomeworkDialogMainState extends State<HomeworkDialogMain> {
return switch (state) {
LoadingHomework() =>
const Center(child: CircularProgressIndicator()),
SavedSucessfully() => throw UnimplementedError(
SavedSuccessfully() => throw UnimplementedError(
'Placeholder, we pop the Navigator above so this should not be reached.'),
Ready() => WillPopScope(
onWillPop: () async => hasModifiedData()
Expand Down
16 changes: 8 additions & 8 deletions app/test/homework/homework_dialog_bloc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ void main() {

await pumpEventQueue();

expect(bloc.state, const SavedSucessfully(isEditing: false));
expect(bloc.state, const SavedSuccessfully(isEditing: false));
expect(
homeworkDialogApi.userInputToBeCreated,
UserInput(
Expand Down Expand Up @@ -423,7 +423,7 @@ void main() {

await pumpEventQueue();

expect(bloc.state, const SavedSucessfully(isEditing: false));
expect(bloc.state, const SavedSuccessfully(isEditing: false));
expect(
homeworkDialogApi.userInputToBeCreated,
UserInput(
Expand Down Expand Up @@ -511,7 +511,7 @@ void main() {
expect(
bloc.presentation, neverEmits(const StartedUploadingAttachments()));

await bloc.stream.whereType<SavedSucessfully>().first;
await bloc.stream.whereType<SavedSuccessfully>().first;
await bloc.close();
});
test(
Expand Down Expand Up @@ -563,7 +563,7 @@ void main() {
expect(
bloc.presentation, neverEmits(const StartedUploadingAttachments()));

await bloc.stream.whereType<SavedSucessfully>().first;
await bloc.stream.whereType<SavedSuccessfully>().first;
await bloc.close();
});
test('Analytics is called when a homework is successfully added', () async {
Expand All @@ -576,7 +576,7 @@ void main() {
bloc.add(CourseChanged(CourseId('foo_course')));
bloc.add(DueDateChanged(Date('2024-03-08')));
bloc.add(const Save());
await bloc.stream.whereType<SavedSucessfully>().first;
await bloc.stream.whereType<SavedSuccessfully>().first;

expect(analyticsBackend.loggedEvents, [
{'homework_add': {}},
Expand All @@ -600,7 +600,7 @@ void main() {

bloc.add(const TitleChanged('new title'));
bloc.add(const Save());
await bloc.stream.whereType<SavedSucessfully>().first;
await bloc.stream.whereType<SavedSuccessfully>().first;

expect(analyticsBackend.loggedEvents, [
{'homework_edit': {}},
Expand Down Expand Up @@ -696,7 +696,7 @@ void main() {
),
);
expect(homeworkDialogApi.removedCloudFilesFromEditing, [attachment1]);
expect(bloc.state, const SavedSucessfully(isEditing: true));
expect(bloc.state, const SavedSuccessfully(isEditing: true));
});
test('Sucessfully displays and edits existing homework 2', () async {
final homeworkId = HomeworkId('bar_homework_id');
Expand Down Expand Up @@ -768,7 +768,7 @@ void main() {
);
expect(homeworkDialogApi.removedCloudFilesFromEditing, []);

expect(bloc.state, const SavedSucessfully(isEditing: true));
expect(bloc.state, const SavedSuccessfully(isEditing: true));
});
});
}
Expand Down

0 comments on commit 56ae7c5

Please sign in to comment.