Skip to content

Commit

Permalink
Remove setting flag
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisPhilippeHeon committed Sep 5, 2024
1 parent 10222d6 commit 108ba97
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 59 deletions.
2 changes: 0 additions & 2 deletions lib/constants/preferences_flags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ enum PreferencesFlag {
// Schedule flags
scheduleCalendarFormat,
scheduleStartWeekday,
// TODO remove
scheduleOtherWeekday,
scheduleShowTodayBtn,
scheduleShowWeekEvents,
scheduleLaboratoryGroup,
Expand Down
8 changes: 0 additions & 8 deletions lib/features/more/settings/settings_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ class SettingsManager with ChangeNotifier {
settings.putIfAbsent(
PreferencesFlag.scheduleStartWeekday, () => startingWeekDay);

final otherWeekDay = await _preferencesService
.getString(PreferencesFlag.scheduleOtherWeekday)
.then((value) => value == null
? WeekDays.monday
: EnumToString.fromString(WeekDays.values, value));
settings.putIfAbsent(
PreferencesFlag.scheduleOtherWeekday, () => otherWeekDay);

final showTodayBtn = await _preferencesService
.getBool(PreferencesFlag.scheduleShowTodayBtn) ??
true;
Expand Down
8 changes: 0 additions & 8 deletions lib/features/schedule/schedule_settings_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ class ScheduleSettingsViewModel

WeekDays? get otherDayOfWeek => _otherDayOfWeek;

set otherDayOfWeek(WeekDays? day) {
setBusy(true);
_settingsManager.setString(PreferencesFlag.scheduleOtherWeekday,
EnumToString.convertToString(day));
_otherDayOfWeek = day;
setBusy(false);
}

/// List of possible days to show in the calendar view
List<WeekDays> otherDayPossible = [
WeekDays.saturday,
Expand Down
16 changes: 1 addition & 15 deletions test/features/more/settings/settings_manager_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ void main() {
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleStartWeekday,
toReturn: null);
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleOtherWeekday,
toReturn: null);
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleCalendarFormat,
toReturn: null);
Expand All @@ -67,7 +64,6 @@ void main() {
remoteConfigServiceMock);

final expected = {
PreferencesFlag.scheduleOtherWeekday: WeekDays.monday,
PreferencesFlag.scheduleStartWeekday: StartingDayOfWeek.monday,
PreferencesFlag.scheduleCalendarFormat: CalendarFormat.week,
PreferencesFlag.scheduleShowTodayBtn: true,
Expand All @@ -82,9 +78,6 @@ void main() {
verify(preferencesServiceMock
.getString(PreferencesFlag.scheduleStartWeekday))
.called(1);
verify(preferencesServiceMock
.getString(PreferencesFlag.scheduleOtherWeekday))
.called(1);
verify(preferencesServiceMock
.getString(PreferencesFlag.scheduleCalendarFormat))
.called(1);
Expand All @@ -106,9 +99,6 @@ void main() {
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleStartWeekday,
toReturn: EnumToString.convertToString(StartingDayOfWeek.sunday));
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleOtherWeekday,
toReturn: EnumToString.convertToString(WeekDays.monday));
PreferencesServiceMock.stubGetString(
preferencesServiceMock, PreferencesFlag.scheduleCalendarFormat,
toReturn: EnumToString.convertToString(CalendarFormat.month));
Expand All @@ -123,7 +113,6 @@ void main() {
toReturn: false);

final expected = {
PreferencesFlag.scheduleOtherWeekday: WeekDays.monday,
PreferencesFlag.scheduleStartWeekday: StartingDayOfWeek.sunday,
PreferencesFlag.scheduleCalendarFormat: CalendarFormat.month,
PreferencesFlag.scheduleShowTodayBtn: false,
Expand All @@ -134,10 +123,7 @@ void main() {
final result = await manager.getScheduleSettings();

expect(result, expected);

verify(preferencesServiceMock
.getString(PreferencesFlag.scheduleOtherWeekday))
.called(1);

verify(preferencesServiceMock
.getString(PreferencesFlag.scheduleStartWeekday))
.called(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ void main() {
testWidgets('Displays no schedule message when there are no events',
(WidgetTester tester) async {
await tester.pumpWidget(localizedWidget(
child: const ScheduleDefault(calendarEvents: [], loaded: true)));
child: const ScheduleDefault(calendarEvents: [], loaded: true, displaySaturday: true)));
await tester.pumpAndSettle();
expect(find.text(intl.no_schedule_available), findsOneWidget);
});

testWidgets('Displays no empty schedule message when loading',
(WidgetTester tester) async {
await tester.pumpWidget(localizedWidget(
child: const ScheduleDefault(calendarEvents: [], loaded: false)));
child: const ScheduleDefault(calendarEvents: [], loaded: false, displaySaturday: true)));
await tester.pumpAndSettle();
expect(find.text(intl.no_schedule_available), findsNothing);
});
Expand Down
24 changes: 0 additions & 24 deletions test/features/schedule/schedule_settings_viewmodel_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,30 +283,6 @@ void main() {
});
});

group("setter scheduleShowWeekendDays - ", () {
test("scheduleShowWeekendDays is updated on the settings", () async {
SettingsManagerMock.stubSetString(
settingsManagerMock, PreferencesFlag.scheduleShowWeekendDays);

const expected = true;

// Call the setter.

viewModel.showWeekendDays = expected;

await untilCalled(settingsManagerMock.setBool(
PreferencesFlag.scheduleShowWeekendDays, any));

expect(viewModel.showWeekendDays, true);
expect(viewModel.isBusy, false);

verify(settingsManagerMock.setBool(
PreferencesFlag.scheduleShowWeekendDays, any))
.called(1);
verifyNoMoreInteractions(settingsManagerMock);
});
});

group("setter startingDayOfWeek - ", () {
test("startingDayOfWeek is updated on the settings", () async {
SettingsManagerMock.stubSetString(
Expand Down

0 comments on commit 108ba97

Please sign in to comment.