54 lines
1.4 KiB
Dart
54 lines
1.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:live_recorder_mobile/core/widgets/status_badge.dart';
|
|
|
|
void main() {
|
|
testWidgets('uses green palette for live status', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: StatusBadge(
|
|
status: 'live',
|
|
label: '直播中',
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
final container = tester.widget<Container>(
|
|
find.descendant(
|
|
of: find.byType(StatusBadge),
|
|
matching: find.byType(Container),
|
|
),
|
|
);
|
|
final decoration = container.decoration! as BoxDecoration;
|
|
|
|
expect(decoration.color, const Color(0xFFECFDF5));
|
|
expect(find.text('直播中'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('falls back to gray palette for unknown status', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: StatusBadge(
|
|
status: 'mystery',
|
|
label: '未知',
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
final container = tester.widget<Container>(
|
|
find.descendant(
|
|
of: find.byType(StatusBadge),
|
|
matching: find.byType(Container),
|
|
),
|
|
);
|
|
final decoration = container.decoration! as BoxDecoration;
|
|
|
|
expect(decoration.color, const Color(0xFFF1F5F9));
|
|
expect(find.text('未知'), findsOneWidget);
|
|
});
|
|
}
|