Files
pluriwave/test/tema/pluriwave_tokens_test.dart
T
FreeTLab ef90a3b849 fix(tokens): correct offlineAccent to the proposal's specified #E8879A
WU1's commit invented an arbitrary value for offlineAccent instead of using
the exact hex the proposal's WU1 scope line already specifies. listSurface
and liveGreen were correctly de-literalised from existing theme.dart
literals; offlineAccent has no prior literal, but its value is still not
this file's discretion — the proposal states #E8879A explicitly.
2026-07-28 20:05:00 +02:00

63 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pluriwave/tema/pluriwave_tokens.dart';
/// Design ADR-1: 3 new colour fields join the existing PluriWaveTokens
/// extension (colours belong here because they must participate in lerp).
/// Dedicated file under test/tema/ so the WU1 verify command
/// (`flutter test test/tema/ ...`) discovers it; the single pre-existing
/// PluriWaveTokens assertion inside pluriwave_foundations_test.dart is left
/// untouched.
void main() {
group('PluriWaveTokens — redesign colours', () {
test('dark keeps the pre-existing base palette', () {
expect(PluriWaveTokens.dark.deepViolet, const Color(0xFF07121A));
expect(PluriWaveTokens.dark.radiusMd, 22);
expect(PluriWaveTokens.dark.spacingMd, 16);
});
test(
'dark exposes listSurface and liveGreen de-literalised from theme.dart',
() {
// Design ADR-1: these match the theme's previous raw literals
// (surfaceContainerLow / secondary) exactly, so promoting them to
// named tokens keeps rendered output byte-identical.
expect(PluriWaveTokens.dark.listSurface, const Color(0xFF102532));
expect(PluriWaveTokens.dark.liveGreen, const Color(0xFF7EE4C2));
},
);
test('dark exposes offlineAccent per the proposal (#E8879A)', () {
expect(PluriWaveTokens.dark.offlineAccent, const Color(0xFFE8879A));
});
test('copyWith overrides only the new colour fields', () {
final overridden = PluriWaveTokens.dark.copyWith(
listSurface: Colors.black,
liveGreen: Colors.black,
offlineAccent: Colors.black,
);
expect(overridden.listSurface, Colors.black);
expect(overridden.liveGreen, Colors.black);
expect(overridden.offlineAccent, Colors.black);
// Untouched fields keep their original value.
expect(overridden.deepViolet, PluriWaveTokens.dark.deepViolet);
});
test('lerp interpolates listSurface, liveGreen and offlineAccent', () {
const a = PluriWaveTokens.dark;
final b = a.copyWith(
listSurface: Colors.white,
liveGreen: Colors.white,
offlineAccent: Colors.white,
);
final mid = a.lerp(b, 0.5);
expect(mid.listSurface, Color.lerp(a.listSurface, Colors.white, 0.5));
expect(mid.liveGreen, Color.lerp(a.liveGreen, Colors.white, 0.5));
expect(mid.offlineAccent, Color.lerp(a.offlineAccent, Colors.white, 0.5));
});
});
}