test(flutter/theme): cover .dark()/.light() factories + back-compat alias
Four cases: dark factory pulls from FabledSwordDarkTokens, light from FabledSwordLightTokens, flat tokens (accent / moss / etc.) are shared between both, and the fromTokens() back-compat alias returns the dark theme. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,26 +1,39 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
import 'package:minstrel/theme/theme_data.dart';
|
|
||||||
import 'package:minstrel/theme/theme_extension.dart';
|
import 'package:minstrel/theme/theme_extension.dart';
|
||||||
import 'package:minstrel/theme/tokens.dart';
|
import 'package:minstrel/theme/tokens.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('Theme exposes FabledSwordTheme with expected accent', (tester) async {
|
test('FabledSwordTheme.dark uses dark surface tokens', () {
|
||||||
late FabledSwordTheme captured;
|
final fs = FabledSwordTheme.dark();
|
||||||
await tester.pumpWidget(
|
expect(fs.obsidian, FabledSwordDarkTokens.obsidian);
|
||||||
MaterialApp(
|
expect(fs.iron, FabledSwordDarkTokens.iron);
|
||||||
theme: buildThemeData(),
|
expect(fs.parchment, FabledSwordDarkTokens.parchment);
|
||||||
home: Builder(
|
});
|
||||||
builder: (ctx) {
|
|
||||||
captured = Theme.of(ctx).extension<FabledSwordTheme>()!;
|
test('FabledSwordTheme.light uses light surface tokens', () {
|
||||||
return const SizedBox.shrink();
|
final fs = FabledSwordTheme.light();
|
||||||
},
|
expect(fs.obsidian, FabledSwordLightTokens.obsidian);
|
||||||
),
|
expect(fs.iron, FabledSwordLightTokens.iron);
|
||||||
),
|
expect(fs.parchment, FabledSwordLightTokens.parchment);
|
||||||
);
|
});
|
||||||
expect(captured.accent, FabledSwordTokens.accent);
|
|
||||||
expect(captured.parchment, FabledSwordTokens.parchment);
|
test('flat tokens (accent, moss, etc.) are shared between factories', () {
|
||||||
expect(captured.body.fontFamily, FabledSwordTokens.fontBody);
|
final dark = FabledSwordTheme.dark();
|
||||||
|
final light = FabledSwordTheme.light();
|
||||||
|
expect(dark.accent, light.accent);
|
||||||
|
expect(dark.moss, light.moss);
|
||||||
|
expect(dark.bronze, light.bronze);
|
||||||
|
expect(dark.oxblood, light.oxblood);
|
||||||
|
expect(dark.warning, light.warning);
|
||||||
|
expect(dark.error, light.error);
|
||||||
|
expect(dark.info, light.info);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('fromTokens() back-compat alias returns the dark theme', () {
|
||||||
|
final alias = FabledSwordTheme.fromTokens();
|
||||||
|
final dark = FabledSwordTheme.dark();
|
||||||
|
expect(alias.obsidian, dark.obsidian);
|
||||||
|
expect(alias.parchment, dark.parchment);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user