Halkyon's shared packages
A pub workspace of the Dart packages Halkyon's apps share: halkyon_ui, Halkyon's look (the theme, fonts, layout and shared widgets, with texts in English and German), halkyon_core's low-level primitives and halkyon_interop's cross-app contracts. Dart 3.13 with LeanCode's lints, configured once at the root; apps take a package by git, pinned to a signed commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
commit
80fa7b9628
1 changed files with 6762 additions and 0 deletions
85
packages/halkyon_ui/test/widget/title_with_kicker_test.dart
Normal file
85
packages/halkyon_ui/test/widget/title_with_kicker_test.dart
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_ui/halkyon_ui.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
void main() {
|
||||
Future<void> show(WidgetTester tester, Widget child) => tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(width: 400, child: child),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
double top(WidgetTester tester, Finder finder) =>
|
||||
tester.getTopLeft(finder).dy;
|
||||
|
||||
testWidgets('shows the kicker uppercased above the title', (tester) async {
|
||||
await show(
|
||||
tester,
|
||||
const TitleWithKicker(title: 'Vocabulary', kicker: 'Japanese'),
|
||||
);
|
||||
|
||||
expect(find.text('JAPANESE'), findsOneWidget);
|
||||
expect(
|
||||
top(tester, find.text('JAPANESE')),
|
||||
lessThan(top(tester, find.text('Vocabulary'))),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('shows the title alone without a kicker', (tester) async {
|
||||
await show(tester, const TitleWithKicker(title: 'Vocabulary', kicker: ''));
|
||||
|
||||
expect(top(tester, find.text('Vocabulary')), 0);
|
||||
});
|
||||
|
||||
testWidgets('can keep the kicker line free, so titles side by side line '
|
||||
'up', (tester) async {
|
||||
await show(
|
||||
tester,
|
||||
const Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TitleWithKicker(title: 'Vocabulary', kicker: 'JLPT'),
|
||||
),
|
||||
Expanded(
|
||||
child: TitleWithKicker(title: 'Grammar', reserveKickerSpace: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
top(tester, find.text('Grammar')),
|
||||
top(tester, find.text('Vocabulary')),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('puts the trailing widget beside the title, not the kicker', (
|
||||
tester,
|
||||
) async {
|
||||
const action = Key('action');
|
||||
await show(
|
||||
tester,
|
||||
const TitleWithKicker(
|
||||
title: 'Vocabulary',
|
||||
kicker: 'Japanese',
|
||||
trailing: SizedBox(key: action, width: 48, height: 48),
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
top(tester, find.byKey(action)),
|
||||
top(tester, find.text('Vocabulary')),
|
||||
);
|
||||
expect(
|
||||
tester.getTopRight(find.byKey(action)).dx,
|
||||
400,
|
||||
reason: 'the title takes the rest of the width',
|
||||
);
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue