51 lines
1.5 KiB
Dart
51 lines
1.5 KiB
Dart
// Author: fruit.com.cn
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/widgets/app_root_tab.dart';
|
|
import 'package:fruitshorts/core/widgets/root_nav_glyph.dart';
|
|
import 'package:fruitshorts/l10n/app_localizations.dart';
|
|
|
|
void main() {
|
|
testWidgets(
|
|
'should_render_five_ordered_glyphs_with_home_selected_when_root_nav_builds',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: Scaffold(
|
|
bottomNavigationBar: AppRootBottomNav(
|
|
selected: AppRootTab.home,
|
|
onSelected: (_) {},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
final glyphs = tester
|
|
.widgetList<RootNavGlyph>(find.byType(RootNavGlyph))
|
|
.toList();
|
|
expect(glyphs.map((glyph) => glyph.kind), RootNavGlyphKind.values);
|
|
expect(glyphs.map((glyph) => glyph.selected), [
|
|
true,
|
|
false,
|
|
false,
|
|
false,
|
|
false,
|
|
]);
|
|
final tabKeys = [
|
|
const Key('tab-home'),
|
|
const Key('tab-recommend'),
|
|
const Key('tab-reward'),
|
|
const Key('tab-follow'),
|
|
const Key('tab-mine'),
|
|
];
|
|
final centers = tabKeys
|
|
.map((key) => tester.getCenter(find.byKey(key)).dx)
|
|
.toList();
|
|
expect(centers, orderedEquals(centers.toList()..sort()));
|
|
},
|
|
);
|
|
}
|