simplified loadable state logic by removing connectivity debouncing and inlining indicator helpers; updated error bar visibility and chat list polling behavior
This commit is contained in:
@@ -1,107 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:marianum_mobile/state/app/infrastructure/loadable_state/loadable_state_indicators.dart';
|
||||
|
||||
void main() {
|
||||
group('shouldShowOfflineBar', () {
|
||||
test('shows when offline with cache and not loading', () {
|
||||
expect(
|
||||
shouldShowOfflineBar(
|
||||
hasContent: true,
|
||||
loading: false,
|
||||
connectivityKnown: true,
|
||||
connected: false,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('is suppressed while loading even if offline with cache', () {
|
||||
expect(
|
||||
shouldShowOfflineBar(
|
||||
hasContent: true,
|
||||
loading: true,
|
||||
connectivityKnown: true,
|
||||
connected: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('is hidden without cached content', () {
|
||||
expect(
|
||||
shouldShowOfflineBar(
|
||||
hasContent: false,
|
||||
loading: false,
|
||||
connectivityKnown: true,
|
||||
connected: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('is hidden while connectivity is unknown', () {
|
||||
expect(
|
||||
shouldShowOfflineBar(
|
||||
hasContent: true,
|
||||
loading: false,
|
||||
connectivityKnown: false,
|
||||
connected: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('is hidden when connected', () {
|
||||
expect(
|
||||
shouldShowOfflineBar(
|
||||
hasContent: true,
|
||||
loading: false,
|
||||
connectivityKnown: true,
|
||||
connected: true,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('shouldRefetch', () {
|
||||
final window = const Duration(seconds: 10);
|
||||
final base = DateTime(2026, 1, 1, 12, 0, 0);
|
||||
|
||||
test('is false within the throttle window', () {
|
||||
expect(
|
||||
shouldRefetch(
|
||||
base,
|
||||
base.add(const Duration(seconds: 9)),
|
||||
window,
|
||||
hasReFetch: true,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
test('is true once the window has elapsed', () {
|
||||
expect(
|
||||
shouldRefetch(
|
||||
base,
|
||||
base.add(const Duration(seconds: 10)),
|
||||
window,
|
||||
hasReFetch: true,
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
test('is false without a refetch callback', () {
|
||||
expect(
|
||||
shouldRefetch(
|
||||
base,
|
||||
base.add(const Duration(minutes: 5)),
|
||||
window,
|
||||
hasReFetch: false,
|
||||
),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user