Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

test: text style tests

Enzo Lizamac0aa90b0b305
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);
+ });
+ });
+}