From c0aa90b0b3058a023cecf22aa5638f3fc9b88c53 Mon Sep 17 00:00:00 2001 From: Enzo Lizama Date: Tue, 4 Oct 2022 22:19:38 -0500 Subject: [PATCH] test: text style tests --- .../extensions/text_style_extension_test.dart | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 frontend/app_flowy/packages/appflowy_editor/test/extensions/text_style_extension_test.dart diff --git a/frontend/app_flowy/packages/appflowy_editor/test/extensions/text_style_extension_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/extensions/text_style_extension_test.dart new file mode 100644 index 0000000000..572178d0f3 --- /dev/null +++ b/frontend/app_flowy/packages/appflowy_editor/test/extensions/text_style_extension_test.dart @@ -0,0 +1,43 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:appflowy_editor/src/extensions/text_style_extension.dart'; + +void main() { + group('TextStyleExtensions::', () { + const style = TextStyle( + color: Colors.blue, + backgroundColor: Colors.white, + fontSize: 14, + height: 100, + wordSpacing: 2, + fontWeight: FontWeight.w700, + ); + + const otherStyle = TextStyle( + color: Colors.red, + backgroundColor: Colors.black, + fontSize: 12, + height: 10, + wordSpacing: 1, + ); + test('combine', () { + final result = style.combine(otherStyle); + expect(result.color, Colors.red); + expect(result.backgroundColor, Colors.black); + expect(result.fontSize, 12); + expect(result.height, 10); + expect(result.wordSpacing, 1); + }); + + test('combine - return this', () { + final result = style.combine(null); + expect(result, style); + }); + + test('combine - return null with inherit', () { + final styleCopy = otherStyle.copyWith(inherit: false); + final result = style.combine(styleCopy); + expect(result, styleCopy); + }); + }); +}