cbc06b2f13
One file at a time or all files stacked is saved in the app's preferences and restored when the app starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.0 KiB
Dart
32 lines
1.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/changes/widgets/diff_layout_preference.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
test('the chosen layout is saved and comes back after a reload', () async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
final first = DiffLayoutPreference();
|
|
await first.restore();
|
|
expect(first.value, isFalse);
|
|
first.value = true;
|
|
await pumpEventQueue();
|
|
// A new app session reads it back.
|
|
final next = DiffLayoutPreference();
|
|
await next.restore();
|
|
expect(next.value, isTrue);
|
|
});
|
|
|
|
test('a choice made while the saved one loads wins', () async {
|
|
SharedPreferences.setMockInitialValues({
|
|
DiffLayoutPreference.storageKey: true,
|
|
});
|
|
final layout = DiffLayoutPreference();
|
|
final restoring = layout.restore();
|
|
layout.value = false;
|
|
await restoring;
|
|
expect(layout.value, isFalse);
|
|
});
|
|
}
|