import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:spotiflac_android/l10n/l10n.dart'; import 'package:spotiflac_android/theme/mornye_theme.dart'; import 'package:spotiflac_android/utils/editorial_notes.dart'; import 'package:spotiflac_android/widgets/album_description.dart'; void main() { test( 'editorial notes prefer full text and fall back to a usable summary', () { expect( albumDescriptionFromMetadata({ 'editorial_notes': { 'standard': '
Full notes.
', 'short': 'Short notes.', }, }), 'Full notes.
', ); expect( albumDescriptionFromMetadata({ 'editorial_notes': { 'standard': '', 'short': 'Short notes.', }, }), 'Short notes.', ); expect( albumDescriptionFromMetadata({'description': 'Plain notes.'}), 'Plain notes.', ); expect(albumDescriptionFromMetadata({'editorial_notes': null}), isNull); expect(albumDescriptionFromMetadata({'editorial_notes': 42}), isNull); expect( albumDescriptionFromMetadata({ 'editorial_notes': {'standard': ''}, }), isNull, ); }, ); for (final style in ['mornye-light', 'mornye-dark', 'material']) { testWidgets('album description opens a formatted reading sheet ($style)', ( tester, ) async { await tester.binding.setSurfaceSize(const Size(393, 700)); addTearDown(() => tester.binding.setSurfaceSize(null)); final mornye = style.startsWith('mornye'); await tester.pumpWidget( ProviderScope( child: MaterialApp( theme: mornye ? MornyeTheme.build( style.endsWith('light') ? Brightness.light : Brightness.dark, ) : ThemeData(), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, home: Navigator( onGenerateRoute: (_) => MaterialPageRoute
The artists explore melodies and new ideas in these songs.
').join()}' 'Final paragraph.
', ), ), ), ), ), ), ); await tester.pumpAndSettle(); final preview = tester.widget