forked from AppFlowy-IO/AppFlowy
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve coverage (AppFlowy-IO#61)
Relates: #16
- Loading branch information
Showing
10 changed files
with
349 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:appflowy_editor/src/render/image/image_upload_widget.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../../infra/test_editor.dart'; | ||
|
||
void main() { | ||
group('ImageUploadMenu tests', () { | ||
testWidgets('showImageUploadMenu', (tester) async { | ||
final editor = tester.editor..insertTextNode('Welcome to AppFlowy'); | ||
await editor.startTesting(); | ||
|
||
await editor.updateSelection( | ||
Selection.single(path: [0], startOffset: 19), | ||
); | ||
|
||
await editor.pressLogicKey(character: '/'); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(find.byType(SelectionMenuWidget), findsOneWidget); | ||
|
||
final imageMenuItemFinder = find.text('Image'); | ||
expect(imageMenuItemFinder, findsOneWidget); | ||
|
||
await tester.tap(imageMenuItemFinder); | ||
await tester.pumpAndSettle(); | ||
}); | ||
|
||
testWidgets('insertImageNode extension', (tester) async { | ||
final editor = tester.editor..insertTextNode('Welcome to AppFlowy'); | ||
await editor.startTesting(); | ||
|
||
await editor.updateSelection( | ||
Selection.single(path: [0], startOffset: 19), | ||
); | ||
|
||
editor.editorState.insertImageNode('no_src'); | ||
await tester.pumpAndSettle(); | ||
|
||
expect(editor.documentLength, 2); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
group('EditorStyle tests', () { | ||
test('extensions', () { | ||
final lightExtensions = lightEditorStyleExtension; | ||
expect(lightExtensions.length, 1); | ||
expect(lightExtensions.contains(EditorStyle.light), true); | ||
|
||
final darkExtensions = darkEditorStyleExtension; | ||
expect(darkExtensions.length, 1); | ||
expect(darkExtensions.contains(EditorStyle.dark), true); | ||
}); | ||
|
||
test('EditorStyle members', () { | ||
EditorStyle style = EditorStyle.light; | ||
expect(style.padding, isNot(EdgeInsets.zero)); | ||
|
||
style = style.copyWith(padding: EdgeInsets.zero); | ||
expect(style.padding, EdgeInsets.zero); | ||
}); | ||
|
||
testWidgets('EditorStyle.of not found', (tester) async { | ||
late BuildContext context; | ||
|
||
await tester.pumpWidget( | ||
Builder(builder: (ctx) { | ||
context = ctx; | ||
return const SizedBox.shrink(); | ||
}), | ||
); | ||
|
||
expect(EditorStyle.of(context), null); | ||
}); | ||
|
||
testWidgets('EditorStyle.of found', (tester) async { | ||
late BuildContext context; | ||
|
||
await tester.pumpWidget( | ||
MaterialApp( | ||
theme: ThemeData.light().copyWith( | ||
extensions: [...lightEditorStyleExtension], | ||
), | ||
home: Builder(builder: (ctx) { | ||
context = ctx; | ||
return const SizedBox.shrink(); | ||
}), | ||
), | ||
); | ||
|
||
final editorStyle = EditorStyle.of(context); | ||
expect(editorStyle, isNotNull); | ||
expect(editorStyle!.backgroundColor, EditorStyle.light.backgroundColor); | ||
}); | ||
|
||
test('EditorStyle.lerp', () { | ||
final editorStyle = | ||
EditorStyle.light.lerp(EditorStyle.dark, 1.0) as EditorStyle; | ||
expect(editorStyle.backgroundColor, EditorStyle.dark.backgroundColor); | ||
}); | ||
}); | ||
} |
Oops, something went wrong.