import 'package:appflowy/plugins/document/application/document_appearance_cubit.dart';
import 'package:appflowy/plugins/document/presentation/editor_style.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';

class MockDocumentAppearanceCubit extends Mock
    implements DocumentAppearanceCubit {}

class MockBuildContext extends Mock implements BuildContext {}

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  group('EditorStyleCustomizer', () {
    late EditorStyleCustomizer editorStyleCustomizer;
    late MockBuildContext mockBuildContext;

    setUp(() {
      mockBuildContext = MockBuildContext();
      editorStyleCustomizer = EditorStyleCustomizer(
        context: mockBuildContext,
        padding: EdgeInsets.zero,
      );
    });

    test('baseTextStyle should return the expected TextStyle', () {
      const fontFamily = 'Roboto';
      final result = editorStyleCustomizer.baseTextStyle(fontFamily);
      expect(result, isA<TextStyle>());
      expect(result.fontFamily, 'Roboto_regular');
    });

    test(
        'baseTextStyle should return the null TextStyle when an exception occurs',
        () {
      const garbage = 'Garbage';
      final result = editorStyleCustomizer.baseTextStyle(garbage);
      expect(result, isA<TextStyle>());
      expect(
        result.fontFamily,
        null,
      );
    });
  });
}
