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:
2026-05-09 15:50:51 -04:00
parent 143130eaae
commit 231f1ddf9a
@@ -1,26 +1,39 @@
import 'package:flutter/material.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/tokens.dart';
void main() {
testWidgets('Theme exposes FabledSwordTheme with expected accent', (tester) async {
late FabledSwordTheme captured;
await tester.pumpWidget(
MaterialApp(
theme: buildThemeData(),
home: Builder(
builder: (ctx) {
captured = Theme.of(ctx).extension<FabledSwordTheme>()!;
return const SizedBox.shrink();
},
),
),
);
expect(captured.accent, FabledSwordTokens.accent);
expect(captured.parchment, FabledSwordTokens.parchment);
expect(captured.body.fontFamily, FabledSwordTokens.fontBody);
test('FabledSwordTheme.dark uses dark surface tokens', () {
final fs = FabledSwordTheme.dark();
expect(fs.obsidian, FabledSwordDarkTokens.obsidian);
expect(fs.iron, FabledSwordDarkTokens.iron);
expect(fs.parchment, FabledSwordDarkTokens.parchment);
});
test('FabledSwordTheme.light uses light surface tokens', () {
final fs = FabledSwordTheme.light();
expect(fs.obsidian, FabledSwordLightTokens.obsidian);
expect(fs.iron, FabledSwordLightTokens.iron);
expect(fs.parchment, FabledSwordLightTokens.parchment);
});
test('flat tokens (accent, moss, etc.) are shared between factories', () {
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);
});
}